I want to know if performing an update in this way will guarantees me an ATOMIC and SERIALIZABLE transaction.
I need to insert some data in a table Y before performing the update in a table X and no one can´t do anything in Table X until i release it.
r.table('TableX', { readMode: 'majority' }).get(IdUser).update(function () {
r.table('TableY').insert({
SomeData: 'Some data will be inserted in Table Y',
SomeData2: 'Some data 2 will be inserted in Table Y',
}).run(conn, (err, results) => {
console.log(results)
})
return { SomeData3: 'Some Data will be updated in TableX' }
}, { nonAtomic: false }).run(conn, function (err, result) {
if (!err && result.replaced > 0)
resolve('OK');
else
reject(new Error(err));
})