How to use the rethinkdb.dbCreate 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 rethinkdb / rethinkdb-example-nodejs / benford / crawler.js View on Github external
}, function(err, conn) {
        if (err) {
            failedAttempts++;
            console.log("Attempt: "+failedAttempts)
            console.error("Could not open a connection to rethinkdb\n"+err.message);

            return setTimeout(init, failedAttempts*5000);
        }

        // Initialize the table with first the database
        r.dbCreate(config.rethinkdb.db).run(conn, function(err, result) {
            // If the database already exists, we'll get an error here, but we'll just keep going
            r.db(config.rethinkdb.db).tableCreate('benford').run(conn, function(err, result) {
                // If the table already exists, we'll get an error here, but we'll just keep going

                var seeds = [];
                for(var i=1; i<10; i++) {
                    seeds.push({id: ""+i, value: 0}); // Note: We use the digit value as the primary key and save it as a string
                }
                r.db(config.rethinkdb.db).table('benford').insert(seeds).run(conn, function(err, result) {
                    // If the database was already initialized, the inserts will not be executed since RethinkDB
                    // does not allow redundant primary keys (`id`)
                    listen();
                });
            });
        });
    });
github thejsj / realtime-photo-tutorial / server / db.js View on Github external
.then(function (conn) {
    r.conn = conn;
    r.connections.push(conn);
    return r.dbCreate(dbConnection.db).run(r.conn)
      .catch(function () {})
      .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 the-control-group / authx / bin / bootstrap.js View on Github external
r.connect(host, function(err, conn) {
	if (err) return error(err);

	// create database
	r.dbCreate(database).run(conn, function(err) {
		if (err) return error(err);

		// load the fixtures
		async.map(fs.readdirSync(__dirname + '/../fixtures/'), function(file, done) {
			var fixture = require(__dirname + '/../fixtures/' + file);

			// create table
			r.db(database).tableCreate(fixture.table).run(conn, function(err) {
				if (err) return done(err);

				// create secondary indices
				async.map(fixture.secondary_indexes, function(index, loop) {
					var q = r.db(database).table(fixture.table);
					q.indexCreate.apply(q, index).run(conn, loop);
				}, function(err) {
					if (err) return done(err);
github davidgljay / nametag / horizon / server / src / metadata / metadata.js View on Github external
const initialize_metadata = (db, conn) =>
  r.branch(r.dbList().contains(db), null, r.dbCreate(db)).run(conn)
    .then(() =>
      Promise.all([ 'hz_collections', 'hz_users_auth', 'hz_groups' ].map((table) =>
        r.branch(r.db(db).tableList().contains(table),
                 { },
                 r.db(db).tableCreate(table))
          .run(conn))))
    .then(() =>
      r.db(db).table('hz_collections').wait({ timeout: 30 }).run(conn))
    .then(() =>
      Promise.all([
        r.db(db).tableList().contains('users').not().run(conn).then(() =>
          create_collection(db, 'users', conn)),
        r.db(db).table('hz_collections')
          .insert({ id: 'hz_metadata', version: metadata_version })
          .run(conn)
      ])
github hoodsy / 3ree-auth-example / server / config / rethinkDb / dbInit.js View on Github external
r.connect(config, (err, conn) => {
    r.dbCreate('anchor')
    .run(conn, (err, res) => {
      conn.close()
      next(err, res)
    })
  })
}
github vizorvr / patches / tools / postinstall.js View on Github external
.then(function(dbList) {
			if (dbList.indexOf(dbName) === -1)
				return r.dbCreate(dbName).run(conn)
		})
		.then(function() {
github hyperledger / sawtooth-core / families / track_and_trade / server / scripts / bootstrap_database.js View on Github external
.then(dbExists => {
        if (dbExists) throw new Error(`"${NAME}" already exists`)
        return r.dbCreate(NAME).run(conn)
      })
      .then(res => {

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