Is it possible to perform a massive upsert, which behaves so that a specific field (for example: createdDT ) is set only during the first update, but not during subsequent recreations of the same record?
EDIT
A rough version has been obtained that works with a server-side loop, where for each element, the result is a conditional insert. Not the most elegant and, most likely, quite effective way of taxation. Any other options?
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) ); }); });
EDIT
These tags and title were not clear: this question relates to rethinkDB
source share