Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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))
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');
});
});
function makeQuery() {
let selector = new FieldSelector({
path: path,
});
return getTerms(
r.db('testdb').table('micropost').merge(
selector.toReQL(r, r.db('testdb'))
)
);
}
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);
}
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);
}
});
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(),
function getWords() {
return r
.db("grand_tour")
.table("words")
.orderBy("word")
.run(connection)
.then(cursor => {
return cursor.toArray();
});
}
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);
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')