1.0.0 • Published 8 years ago

rethink-init v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

rethink-init

Initialize / sync Rethinkdb tables and indexes (built to be used with seedalpha/rethink)

Installation

$ npm install rethink-init --save

Usage

var init  = require('rethink-init');
var r     = require('rethinkdb');

var options = {
  host: 'localhost',
  port: 28015,
  db: 'test'
};

var schema = {
  comments: {
    options: {
      primaryKey: 'id',
      durability: 'soft',
      shards: 2,
      replicas: 2
    },
    indexes: {
      author: true,
      article: true,
      location: { geo: true },
      tags: { multi: true }
    }
  }
}

function connect(opts, cb) {
  r.connect(options, function(err, connection) {
    if (err) return cb(err);
    init(schema, r, connection, cb);
  });
}

connect(options, function(err, connection) {
  if (err) return console.log('Error:', err);
  console.log('Tables and indexes are synced');
});

Supported options

library supports main initialization options for table and index creation.

Notes:

  • table primaryReplicaTag option is not supported
  • index indexFunction is not supported yet

Development

$ git clone git@github.com:seedalpha/rethink-init.git
$ cd rethink-init
$ npm install
$ npm test

Author

Vladimir Popov vlad@seedalpha.net

License

MIT