Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
collection.table.get(new_row('id')).replace((old_row) =>
r.branch(
old_row.eq(null),
r.branch(
// Error if we were expecting the row to exist
new_row.hasFields(hz_v),
r.error(writes.invalidated_msg),
// Otherwise, insert the row
writes.apply_version(new_row, 0)
),
r.branch(
// The row may have changed from the expected version
r.and(new_row.hasFields(hz_v),
old_row(hz_v).default(-1).ne(new_row(hz_v))),
r.error(writes.invalidated_msg),
// Otherwise, we can safely overwrite the row
writes.apply_version(new_row, old_row(hz_v).default(-1).add(1))
)
), { returnChanges: 'always' }),
collection.table.get(new_row('id')).replace((old_row) =>
r.branch(
old_row.eq(null),
r.branch(
// Error if we were expecting the row to exist
new_row.hasFields(hz_v),
r.error(writes.invalidated_msg),
// Otherwise, insert the row
writes.apply_version(new_row, 0)
),
r.branch(
// The row may have changed from the expected version
r.and(new_row.hasFields(hz_v),
old_row(hz_v).default(-1).ne(new_row(hz_v))),
r.error(writes.invalidated_msg),
// Otherwise, we can safely update the row and increment the version
.forEach((new_row) =>
r.branch(new_row.hasFields('id'),
collection.table.get(new_row('id')).replace((old_row) =>
r.branch(
old_row.eq(null),
r.branch(
// Error if we were expecting the row to exist
new_row.hasFields(hz_v),
r.error(writes.invalidated_msg),
// Otherwise, insert the row
writes.apply_version(new_row, 0)
),
r.branch(
// The row may have changed from the expected version
r.and(new_row.hasFields(hz_v),
old_row(hz_v).default(-1).ne(new_row(hz_v))),
r.error(writes.invalidated_msg),
r.range(row_data.count()).map((index) =>
r.branch(res('changes')(index)('old_val').eq(null),
res('changes')(index).merge({ old_val: { id: row_data(index)('id') } }),
res('changes')(index))).coerceTo('array'),
})))
r.dbList().contains(config.rethinkdb.db).do(function(containsDb) {
return r.branch(
containsDb,
{created: 0},
r.dbCreate(config.rethinkdb.db)
);
}).run(connection, function(err) {
callback(err, connection);
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}`);
}
r.tableList().contains('todos').do(function(containsTable) {
return r.branch(
containsTable,
{created: 0},
r.tableCreate('todos')
);
}).run(connection, function(err) {
callback(err, connection);
.do(foundBlock => {
return r.branch(foundBlock, foundBlock, blocks.insert(block))
})
})
internals.empty = function (path) {
const selector = path.reduce((memo, next) => memo(next), exports.row);
return RethinkDB.branch(
selector.typeOf().eq('ARRAY'), selector.isEmpty(),
selector.typeOf().eq('OBJECT'), selector.keys().isEmpty(),
false);
};
.do(exists => {
return r.branch(
exists,
{
tables_created: 0
},
r.db("grand_tour").tableCreate("words", {
replicas: 3
})
);
})
.run(connection);