How to use the rethinkdb.dbList 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 hyperledger / sawtooth-core / families / track_and_trade / server / scripts / bootstrap_database.js View on Github external
.then(conn => {
    console.log(`Creating "${NAME}" database...`)
    r.dbList().contains(NAME).run(conn)
      .then(dbExists => {
        if (dbExists) throw new Error(`"${NAME}" already exists`)
        return r.dbCreate(NAME).run(conn)
      })
      .then(res => {
        console.log('Creating "users" table...')
        return r.db(NAME).tableCreate('users', {
          primaryKey: 'publicKey'
        }).run(conn)
      })
      .then(res => {
        // The usernames table is used to quickly ensure unique usernames
        console.log('Creating "usernames" table...')
        return r.db(NAME).tableCreate('usernames', {
          primaryKey: 'username'
        }).run(conn)
github mike-engel / bkmrkd / server.js View on Github external
function createDatabase () {
  rethink.dbList().run(connection, (err, dbs) => {
    if (err) {
      throw new Error('Error getting the list of databases: ', err)
    }

    if (dbs.indexOf('bkmrkd') === -1) {
      rethink.dbCreate('bkmrkd').run(connection, (err, response) => {
        if (err) {
          throw new Error('Error creating the bkmrkd database: ', err)
        }

        console.info('Created the bkmrkd database')
      })
    }

    bkmrkd = rethink.db('bkmrkd')
github reicek / PostgreSQL_RESTful_API / nodeServer.js View on Github external
.then(function(conn) {
		console.log('_____________________');
		console.log("Conection stablished");
		console.log("Checking DB...");
		r.dbList().run(conn)
			.then(function(dbList){
				if (dbList.indexOf(config.rethinkdb.db) > -1)
				{
					initialize(conn);
				} else {
					console.log("The DB doesn't exist.");
					console.log("Initializing DB "+config.rethinkdb.db);
					r.dbCreate(config.rethinkdb.db).run(conn)
						.then(initialize(conn))
				}
			})
	})
	.error(function(error){
github rethinkdb / 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 pedromsilvapt / unicast / src / Database / Database.ts View on Github external
async install () {
        try {
            const databaseName : string = this.config.get( 'database.db' );

            const conn = await this.connections.acquire();
    
            try {
                const databases = await r.dbList().run( conn );
        
                if ( !databases.includes( databaseName ) ) {
                    await r.dbCreate( databaseName ).run( conn );
                }
        
                await ( r.db( databaseName ) as any ).wait().run( conn );

                await this.tables.install();

                await this.onInstall.notify();

                await ( r.db( databaseName ) as any ).wait().run( conn );
            } finally {
                await this.connections.release( conn );
            }
github GordyD / 3ree / dbSetup.js View on Github external
function getDbList(conn) {
  return r.dbList().run(conn);
}
github hoodsy / 3ree-auth-example / server / config / dbSetup.js View on Github external
function getDbList(conn) {
  return r.dbList().run(conn);
}
github ediket / graphql-relay-rethinkdb-example / bin / sync.js View on Github external
async function syncDB() {
  const connection = await getConnection({ db: null });
  r.branch(
    r.dbList().contains(RETHINKDB.DB).not(),
    r.dbCreate(RETHINKDB.DB),
    null
  ).run(connection);
  await connection.close();
}

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