How to use the rethinkdb.db function in rethinkdb

To help you get started, we’ve selected a few rethinkdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidgljay / nametag / horizon / cli / src / migrate.js View on Github external
function validateMigration () {
  // check that `${project}_internal` exists
  const project = this.options.project_name
  const internalNotFound = `Database named '${project}_internal' wasn't found`
  const tablesHaveHzPrefix = `Some tables in ${project} have an hz_ prefix`
  const checkForHzTables = r.db('rethinkdb')
          .table('table_config')
          .filter({ db: project })('name')
          .contains((x) => x.match('^hz_'))
          .branch(r.error(tablesHaveHzPrefix), true)
  const waitForCollections = r.db(`${project}_internal`)
          .table('collections')
          .wait({ timeout: 30 })
          .do(() => r.db(project).tableList())
          .forEach((tableName) =>
            r.db(project).table(tableName).wait({ timeout: 30 })
          )

  return Promise.resolve().then(() => {
    white('Validating current schema version')
    return r.dbList().contains(`${project}_internal`)
      .branch(true, r.error(internalNotFound))
github rethinkdb / horizon / cli / src / migrate.js View on Github external
function validateMigration() {
  // check that `${project}_internal` exists
  const project = this.options.project_name;
  const internalNotFound = `Database named '${project}_internal' wasn't found`;
  const tablesHaveHzPrefix = `Some tables in ${project} have an hz_ prefix`;
  const checkForHzTables = r.db('rethinkdb')
          .table('table_config')
          .filter({ db: project })('name')
          .contains((x) => x.match('^hz_'))
          .branch(r.error(tablesHaveHzPrefix), true);
  const waitForCollections = r.db(`${project}_internal`)
          .table('collections')
          .wait({ timeout: 30 })
          .do(() => r.db(project).tableList())
          .forEach((tableName) =>
            r.db(project).table(tableName).wait({ timeout: 30 })
          );

  return Promise.resolve().then(() => {
    white('Validating current schema version');
    return r.dbList().contains(`${project}_internal`)
      .branch(true, r.error(internalNotFound))
github reindexio / reindex-api / test / query / converters / CoerceConverter.js View on Github external
it('Should add coerceTo to query', () => {
    let converter = new CoerceConverter({
      to: 'array',
    });
    let query = r.db('testdb').table('micropost');

    let result = getTerms(
      converter.toReQL(r, r.db('testdb'), query)
    ).first();
    assert.equal(result.op, 'COERCE_TO');
    assert.equal(result.args.first(), 'array');
  });
});
github reindexio / reindex-api / test / query / selectors / FieldSelector.js View on Github external
function makeQuery() {
    let selector = new FieldSelector({
      path: path,
    });

    return getTerms(
      r.db('testdb').table('micropost').merge(
        selector.toReQL(r, r.db('testdb'))
      )
    );
  }
github reindexio / reindex-api / test / query / selectors / FieldSelector.js View on Github external
function makeClosureQuery() {
    let selector = new FieldSelector({
      path: path,
    });

    return getNestedQueryArgument(getTerms(
      r.db('testdb').table('micropost').merge((obj) => {
        return selector.toReQL(r, r.db('testdb'), {obj});
      })
    ), 0);
  }
github rystsov / perseus / rethinkdb / client / app / src / init.js View on Github external
r.connect({host: "rethink1", port: 28016}, function(err, conn) {
    if (err) {
        console.info(err);
        process.exit(1);
    } else {
        r.db("test").tableCreate("lily", {
            durability: "hard",
            replicas: 3
        }).run(conn, function(err, result) {
            if (err) {
                if (err.msg.includes("already exists")) {
                    console.info("test.lily created");
                    process.exit(0);
                } else {
                    console.info(err);
                    process.exit(1);
                }
            } else {
                console.info("test.lily created");
                process.exit(0);
            }
        });
github mikemintz / rethinkdb-websocket-server / src / ReqlTermExamples.js View on Github external
COERCE_TO: r([]).coerceTo(),
  TYPE_OF: r([]).typeOf(),
  UPDATE: r([]).update({}),
  DELETE: r([]).delete(),
  REPLACE: r([]).replace({}),
  INSERT: r([]).insert({}),
  DB_CREATE: r.dbCreate(),
  DB_DROP: r.dbDrop(),
  DB_LIST: r.dbList(),
  TABLE_CREATE: r.tableCreate(''),
  TABLE_DROP: r.tableDrop(''),
  TABLE_LIST: r.tableList(),
  CONFIG: r([]).config(),
  STATUS: r([]).status(),
  WAIT: r.db('').wait(),
  RECONFIGURE: r.db('').reconfigure(),
  REBALANCE: r.db('').rebalance(),
  SYNC: r([]).sync(),
  INDEX_CREATE: r([]).indexCreate(''),
  INDEX_DROP: r([]).indexDrop(''),
  INDEX_LIST: r([]).indexList(),
  INDEX_STATUS: r([]).indexStatus(),
  INDEX_WAIT: r([]).indexWait(),
  INDEX_RENAME: r([]).indexRename('', ''),
  FUNCALL: r.do(() => 0),
  BRANCH: r.branch(0, 0, 0),
  OR: r(0).or(0),
  AND: r(0).and(0),
  FOR_EACH: r([]).forEach(() => 0),
  FUNC: r(() => 0),
  ASC: r.asc(),
  DESC: r.desc(),
github compose-grandtour / node / example-rethinkdb / server.js View on Github external
function getWords() {
  return r
    .db("grand_tour")
    .table("words")
    .orderBy("word")
    .run(connection)
    .then(cursor => {
      return cursor.toArray();
    });
}
github rethinkdb / horizon / server / src / metadata / metadata.js View on Github external
const create_collection = (db, name, conn) =>
  r.db(db).table('hz_collections').get(name).replace({ id: name }).do((res) =>
    r.branch(
      res('errors').ne(0),
      r.error(res('first_error')),
      res('inserted').eq(1),
      r.db(db).tableCreate(name),
      res
    )
  ).run(conn);
github jmdobry / RequelPro / src / RequelPro / models / database.js View on Github external
return table.merge({
              shards: table('shards').map(shard => {
                return shard.merge({
                  replicas: shard('replicas').innerJoin(
                    r.db('rethinkdb')
                      .table('stats', { identifier_format: 'uuid' })
                      .filter(stat => stat('table').eq(table('id')).and(stat.hasFields('storage_engine')))
                      .without('id', 'table', 'db'),
                    (replicaRow, statRow) => replicaRow('server').eq(statRow('server'))
                  ).zip()
                    .eqJoin('server', r.db('rethinkdb').table('server_status', { identifier_format: 'uuid' }))
                    .zip()
                    .coerceTo('array')
                });
              }).coerceTo('array'),
              indexes: r.db(this.name).table(table('name')).indexStatus().without('function').coerceTo('array')
            });
          })
          .coerceTo('array')

rethinkdb

This package provides the JavaScript driver library for the RethinkDB database server for use in your node application.

Unknown
Latest version published 4 years ago

Package Health Score

61 / 100
Full package analysis