A Knex adapter for thinodium, allowing you to connect to relational database engines supported by Knex.
This adapter will NOT create tables, relations and indices for you. Instead we recommend using Knex's built-in seeding and migration functionality to do that.
WARNING: When inserting rows the RETURNING
clause is used to fetch the id
of the inserted row - this is then set on the returned document. But this clause
only works for Postgres, MSSQL and Oracle.
For other database engines do not
rely on the id in the returned object, i.e. freshly fetch the inserted data
manually.
$ npm install thinodium thinodium-knex
const Thinodium = require('thinodium');
const db = yield Thinodium.connect('knex', {
/* knex configuration options - see http://knexjs.org/#Installation-client */
});
// Get a builder for the "User" table. The table must already exist!
const User = yield db.model('User');
// insert a new user
let user = yield User.insert({
name: 'john'
});
// ... normal thinodium API methods available at this point
Check out the thinodium docs for further usage examples and API docs.
Install Postgres and create the test user (use thinodium
as the password when prompted):
$ createuser -d -l -r -s -W thinodium
$ createdb thinodium_knex
On the command-line:
$ npm install
$ npm test
Contributions are welcome! Please see CONTRIBUTING.md.
MIT - see LICENSE.md