How to use the rethinkdb.tableList 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 thejsj / realtime-photo-tutorial / server / db.js View on Github external
.then(function () {
        r.conn.use(dbConnection.db);
        // Create Tables
        return r.tableList().run(r.conn)
          .then(function (tableList) {
            return q()
              .then(function() {
                if (tableList.indexOf('images') === -1) {
                  return r.tableCreate('images').run(r.conn);
                }
              });
          });
      });
  });
github jmdobry / waterline-rethinkdb / lib / adapter.js View on Github external
RethinkDBAdapter.prototype.drop = function drop(collectionName, cb) {

	var _this = this;

	// Drop the table if it exists
	this.connectionRun(r.tableList(), function (err, tableList) {
		if (tableList && _.indexOf(tableList, collectionName) !== -1) {
			_this.connectionRun(r.tableDrop(collectionName), function (err, result) {
				if (err) {
					cb(err);
				} else if (result.dropped !== 1) {
					cb('Failed to drop table: ' + collectionName);
				} else {
					cb();
				}
			});
		} else {
			cb();
		}
	});
};
github lautiamkok / koa-realtime / server / index.js View on Github external
const deleteUser = async(ctx, next) => {
  await next()

  // Get the db connection.
  const connection = await db()

  // Throw the error if the table does not exist.
  var exists = await r.tableList().contains('users').run(connection)
  if (exists === false) {
    ctx.throw(500, 'users table does not exist')
  }

  let body = ctx.request.body || {}

  // Throw the error if no id.
  if (body.id === undefined) {
    ctx.throw(400, 'id is required')
  }

  let objectId = body.id

  // Delete a single document by id.
  // https://rethinkdb.com/api/javascript/delete/
  var result = await r.table('users')
github thejsj / rethinkdb-proxy / test / database-and-table-access.js View on Github external
.then(function (conn) {
            return r.tableList().run(conn);
          })
          .then(throwError, expectError.bind(null, 'ReqlDriverError', /DATABASE/i))
github ediket / nothinkdb / src / Table.js View on Github external
static async ensureTable(connection) {
    await r.branch(
      r.tableList().contains(this.table).not(),
      r.tableCreate(this.table),
      null
    ).run(connection);
  }
github reindexio / reindex-api / db / rethinkdb / migrations / 0001_createReindexHook.js View on Github external
async function main() {
  await runMigration([
    RethinkDB.do(
      RethinkDB.tableList(),
      (tables) =>
        RethinkDB.branch(
          tables.contains('ReindexHook'),
          {},
          RethinkDB.tableCreate('ReindexHook')
        )
    ),
  ]);
}
github jolson88 / CoreOS-GettingStarted / EndToEnd / src / hello.js View on Github external
}).then(() => {
                return r.tableList().contains('settings').run(conn).then((exists) => {
                    if (!exists) {
                        return r.tableCreate('settings').run(conn).then(() => {
                            return r.table('settings').insert({ name: 'Prompt', value: 'Hello' }).run(conn);
                        });
                    } else {
                        return Promise.resolve();
                    }
                });
            });
        });
github ediket / nothinkdb / src / Table.js View on Github external
async ensureTable(connection) {
    debug(`ensureTable ${connection.db}.${this.tableName}...`);
    await r.branch(
      r.tableList().contains(this.tableName).not(),
      r.tableCreate(this.tableName),
      null
    ).run(connection);
    debug(`[done] ensureTable ${connection.db}.${this.tableName}`);
  }
github ktbartholomew / tic-tac-toe / db-schema / index.js View on Github external
.then(function () {
    return r.tableList().run(Connection);
  })
  .then(function (tables) {

rethinkdb

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

Unknown
Latest version published 5 years ago

Package Health Score

58 / 100
Full package analysis