Gee*_*Jan 5 rethinkdb rethinkdb-javascript
是否可以执行大量upsert,其行为使得特定字段(例如createdDT:)仅在第一次upsert时设置,而不是在同一记录的后续upsert期间设置?
编辑
有一个原始版本工作,它执行服务器端执行循环,其中每个元素的查找后跟一个条件插入.不是最优雅,也可能是相当可观的性能.还有其他选择吗?
const tableName = "someTableName";
return r.expr(objs).forEach(function (docToInsert) {
return r.table(tableName).get(docToInsert('id')).replace(function (existingDoc) {
return r.branch(
existingDoc.eq(null),
r.expr(docToInsert).merge({ createdDT: r.now() }),
existingDoc.merge(docToInsert)
);
});
});
Run Code Online (Sandbox Code Playgroud)
编辑
标签和标题都不清楚:这个问题与rethinkDB有关
| 归档时间: |
|
| 查看次数: |
144 次 |
| 最近记录: |