@adt-it/rethink-init

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

Usage no npm install needed!

<script type="module">
  import adtItRethinkInit from 'https://cdn.skypack.dev/@adt-it/rethink-init';
</script>

README

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