knex / knex

A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.
https://knexjs.org/
MIT License
19.33k stars 2.12k forks source link

Documentation for passing custom dialect / client for knex. #5836

Open elhigu opened 6 years ago

elhigu commented 6 years ago

Original issue / PR of the feature found here https://github.com/tgriesser/knex/issues/1440 and https://github.com/tgriesser/knex/pull/1428 and other usage example here https://github.com/tgriesser/knex/issues/2285

webleaf commented 5 years ago

Can you give example of defining custom Client? I have not standard sqlite driver and want implement Client for it. What interface for driver I have to implement?

kibertoad commented 5 years ago

@elhigu Correct me if I'm wrong, but probably custom dialect is going to be identical to any existing dialect, right? @webleaf So you basically you can take https://github.com/tgriesser/knex/tree/master/src/dialects/sqlite3 folder as a basic of what a custom dialect is supposed to look like (as a client you would pass instance of https://github.com/tgriesser/knex/blob/master/src/dialects/sqlite3/index.js)

webleaf commented 5 years ago

@kibertoad thank you for answer. What this method should return? https://github.com/tgriesser/knex/blob/461868b61491ab6bccbadc719449718a69399558/src/dialects/sqlite3/index.js#L33-L35 Does is it used internally by knex? Because in my case instead node sqlite3, I have own with other interface.

kibertoad commented 5 years ago

@webleaf This sounds something for internal use mostly, so whatever external dependency you rely on, I think, if any.

elhigu commented 5 years ago

In contributing.md is example code for it. If driver API is different you probably need to override more stuff, but you can start with that driver and probably query methods and how to create connections.