Skip to content

thinodium/thinodium-rethinkdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thinodium RethinkDB adapter

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

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

Releases

No releases published

Packages

No packages published