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

Typings: Add knex() method type to QueryBuilder #2379

Merged
merged 1 commit into from Apr 14, 2023

Conversation

pigpudle
Copy link
Contributor

@pigpudle pigpudle commented Apr 7, 2023

Objection.js allows us to get Knex instance from QueryBuilder by using .knex() method like this:

await ModelName.query(trx).knex().raw(query);

Source code: https://github.com/Vincit/objection.js/blob/master/lib/queryBuilder/QueryBuilderOperationSupport.js#L194

But this method is not defined in types definitions. Thus TypeScript shows an error like Property 'knex' does not exist on type 'QueryBuilder<ModelName, ModelName[]>' when using the above code.

This PR adds .knex() method definition to QueryBuilder types.

@pigpudle pigpudle changed the title Add knex method type to QueryBuilder Typings: Add knex() method type to QueryBuilder Apr 7, 2023
@lehni
Copy link
Collaborator

lehni commented Apr 14, 2023

Looks good, thank you @pigpudle!

@lehni lehni merged commit 32c2d2e into Vincit:master Apr 14, 2023
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

Successfully merging this pull request may close these issues.

None yet

3 participants