Skip to content

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.

3 participants