Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var createTable = function() {
r
.tableCreate( connectionParams.testTable, {
primaryKey: connectionParams.primaryKey,
durability: 'hard'
} )
.run( connection, fn( populateTable ) );
};
if ((err) && (!err.message.match(/Database `.*` already exists/))) {
console.log("Could not create the database `" + config.rethinkdb.db + "`");
console.log(err);
process.exit(1);
}
console.log('Database `' + config.rethinkdb.db + '` created.');
r.tableCreate('user').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `users`");
console.log(err);
process.exit(1);
}
console.log('Table `users` created.');
});
r.tableCreate('restaurant').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `users`");
console.log(err);
process.exit(1);
}
console.log('Table restaurant created');
r.table('restaurant').indexCreate('userID').run(conn);
});
r.tableCreate('order').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `order`");
console.log(err);
process.exit(1);
}
r.table('order').indexCreate('userID').run(conn);
r.table('order').indexCreate('restaurantID').run(conn);
r.dbCreate(config.rethinkdb.db).run(conn, function(err, result) {
if ((err) && (!err.message.match(/Database `.*` already exists/))) {
console.log("Could not create the database `" + config.rethinkdb.db + "`");
console.log(err);
process.exit(1);
}
console.log('Database `' + config.rethinkdb.db + '` created.');
r.tableCreate('user').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `users`");
console.log(err);
process.exit(1);
}
console.log('Table `users` created.');
});
r.tableCreate('restaurant').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `users`");
console.log(err);
process.exit(1);
}
console.log('Table restaurant created');
r.table('restaurant').indexCreate('userID').run(conn);
});
console.log("Could not create the table `users`");
console.log(err);
process.exit(1);
}
console.log('Table `users` created.');
});
r.tableCreate('restaurant').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `users`");
console.log(err);
process.exit(1);
}
console.log('Table restaurant created');
r.table('restaurant').indexCreate('userID').run(conn);
});
r.tableCreate('order').run(conn, function(err, result) {
if ((err) && (!err.message.match(/Table `.*` already exists/))) {
console.log("Could not create the table `order`");
console.log(err);
process.exit(1);
}
r.table('order').indexCreate('userID').run(conn);
r.table('order').indexCreate('restaurantID').run(conn);
console.log('Table `order` created.');
});
});
}
.then(function() {
if (tableList.indexOf('images') === -1) {
return r.tableCreate('images').run(r.conn);
}
});
});
.finally( () => r.tableCreate('artists').run(conn) )
.finally( () => r.table('artists').indexCreate('createdAt').run(conn) )
r.dbCreate(config.rethinkdb.db).run(conn).finally(function() {
return r.tableCreate('todos').run(conn)
}).finally(function() {
r.table('todos').indexCreate('createdAt').run(conn);
function createTable(table, options) {
var tableOptions = {
primaryKey: options.primaryKey
}
return r.tableCreate(table, tableOptions).run(conn)
.then(function() {
log.info('Table "%s" created', table)
})
.catch(alreadyExistsError, function() {
log.info('Table "%s" already exists', table)
return Promise.resolve()
})
.catch(noMasterAvailableError, function() {
return Promise.delay(1000).then(function() {
return createTable(table, options)
})
})
.then(function() {
if (options.indexes) {
return Promise.all(Object.keys(options.indexes).map(function(index) {
return createIndex(table, index, options.indexes[index])
static async ensureTable(connection) {
await r.branch(
r.tableList().contains(this.table).not(),
r.tableCreate(this.table),
null
).run(connection);
}
function createTable(cb) {
rdb.tableCreate(TABLE, {primaryKey: 'tsid'}).run(conn, cb);
},
function loadFixture(cb) {