thinodium-rethinkdb
v1.2.0
Published
RethinkDB adapter for Thinodium ODM library
Downloads
13
Maintainers
Readme
Thinodium RethinkDB adapter
A RethinkDB adapter for thinodium which internally uses rethinkdbdash.
Features:
- Creates tables and indexes if they don't already exist.
Installation
$ npm install thinodium thinodium-rethinkdb
Usage examples
const Thinodium = require('thinodium');
const db = yield Thinodium.connect('rethinkdb', {
// db name
db: 'mydb',
/* all options get passed to rethinkdbdash module */
...
});
/*
This will create the "User" table and all specifies indexes if they
don't already exist.
*/
const User = yield db.model('User', {
indexes: [
// single-value field
{
name: 'username',
},
// a multivalue field
{
name: 'roles',
options: {
multi: true,
},
},
// totally custom indexing function
{
name: 'email',
def: function(doc) {
return doc('emails')('email');
},
options: {
multi: true,
},
},
],
});
// 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
To run the tests you will need RethinkDB installed and running with default host and port settings. Then on the command-line:
$ npm install
$ npm test
Contributing
Contributions are welcome! Please see CONTRIBUTING.md.
License
MIT - see LICENSE.md