https://github.com/thinodium/thinodium-knex
Knex adapter for Thinodium ODM library for working with relational databases
https://github.com/thinodium/thinodium-knex
database knex nodejs odm postgres relational-databases sqlite
Last synced: 5 months ago
JSON representation
Knex adapter for Thinodium ODM library for working with relational databases
- Host: GitHub
- URL: https://github.com/thinodium/thinodium-knex
- Owner: thinodium
- Created: 2016-12-28T12:40:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-15T18:53:32.000Z (over 9 years ago)
- Last Synced: 2025-09-28T10:29:25.713Z (9 months ago)
- Topics: database, knex, nodejs, odm, postgres, relational-databases, sqlite
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Thinodium Knex adapter
[](http://travis-ci.org/thinodium/thinodium-knex)
[](https://www.npmjs.com/package/thinodium-knex)
[](https://discord.gg/bYt4tWB)
[](https://twitter.com/hiddentao)
A [Knex](http://knexjs.org/) adapter for [thinodium](https://github.com/thinodium/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](http://knexjs.org/#Migrations)
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](http://knexjs.org/#Builder-returning).
For other database engines do not
rely on the id in the returned object, i.e. freshly fetch the inserted data
manually.**
## Installation
```bash
$ npm install thinodium thinodium-knex
```
## Usage examples
```js
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](https://hiddentao.github.io/thinodium) for further usage examples and API docs.
## Building
Install Postgres and create the test user (use `thinodium` as the password when prompted):
```bash
$ 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](https://github.com/thinodium/thinodium-knex/blob/master/CONTRIBUTING.md).
## License
MIT - see [LICENSE.md](https://github.com/thinodium/thinodium-knex/blob/master/LICENSE.md)