@adt-it/rethink-init

2.1.0 • Public • Published

rethink-init

prepares rethinkdb for usage by creating tables and indices based on config parameters

##Usage

var rethink = require('@adt-it/config-loader');

let r = await rethink.init({
	connection: {
		host: "localhost",
		port: 28015,
		db: "test",
		user: "admin",
		password: ""
	},
	tables: {
		TableA: {
			[...]
		},
		TableB: {
			[...]
		}
	}
});


//let r = rethink.r;
//let conn = rethink.conn;

let dataB = await rethink.table('TableA').run(rethink.conn).then(rethink.toArray);
console.log('dataB');

let dataB = await r.db('test').table('TableB').run(rethink.conn).then(rethink.toArray);
console.log('dataB');

##Events

  • connection-ready - When db connection is established and rethink.conn is available
  • tables-ready - When tables have been prepared and rethink.table() can be used
  • ready - When init is completed and everything is running

Package Sidebar

Install

npm i @adt-it/rethink-init

Weekly Downloads

1

Version

2.1.0

License

UNLICENSED

Unpacked Size

5.05 kB

Total Files

3

Last publish

Collaborators

  • tbessenreither