Skip to content

Knex adapter for Thinodium ODM library for working with relational databases

Notifications You must be signed in to change notification settings

thinodium/thinodium-knex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thinodium Knex adapter

Build Status npm Join the chat at https://discord.gg/bYt4tWB Follow on Twitter

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.

Installation

$ npm install thinodium thinodium-knex

Usage examples

const Thinodium = require('thinodium');

const db = yield Thinodium.connect('knex', {
  /* knex configuration options - see http:https://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.

Building

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

Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

License

MIT - see LICENSE.md

About

Knex adapter for Thinodium ODM library for working with relational databases

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published