Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an on "create" handler? #2

Closed
SomethingSexy opened this issue Jun 21, 2021 · 3 comments
Closed

Add an on "create" handler? #2

SomethingSexy opened this issue Jun 21, 2021 · 3 comments

Comments

@SomethingSexy
Copy link

SomethingSexy commented Jun 21, 2021

Trying to test a query with 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"'. Looks like the rawQuery is coming in as

      {
        method: 'create',
        sql: 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"',
        bindings: [],
        options: {},
        __knexQueryUid: 'YWbkHLXSCbrMkF-4EbyRi',
        queryContext: undefined
      }

But I think we would need a create method added to tracker.on to support this. Or is there another way to handle this?

@felixmosh
Copy link
Owner

Since it is Postgres specific query, I don't think that the tracker should have create handler.

Maybe it is better to add any handler which these handlers will be used for any type of queries.
WDYT?

@felixmosh
Copy link
Owner

In v1.4.0 there is a new any method which capture any query type.
Usage will look like:

const affectedRows = 1;
tracker.on
  .any((rawQuery) => rawQuery.method === 'create' && rawQuery.sql.includes('"uuid-ossp"'))
  .response(affectedRows);

@SomethingSexy
Copy link
Author

Thanks! I will check this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants