Initialize / sync Rethinkdb tables and indexes (built to be used with seedalpha/rethink)
$ npm install rethink-init --save
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');
});
library supports main initialization options for table and index creation.
Notes:
- table
primaryReplicaTag
option is not supported - index
indexFunction
is not supported yet
$ git clone git@github.com:seedalpha/rethink-init.git
$ cd rethink-init
$ npm install
$ npm test
Vladimir Popov vlad@seedalpha.net
MIT