Say I have a document
{
id: 1,
fruits: []
}
The fruits here act like SET
Now I want to atomically add a value for a fruit array for a document with primary key = 1 OR create such a document if it does not exist (for example, use SetInsert ReQL under the hood)
I also need to do the same for increment (ReQL.Add)
Obviously this cannot be done in client code, as it breaks atomicity, and I end up with inconsistent data
I wish something like this were possible
r.table('results').insert({
id: '62c70132-6516-4279-9803-8daf407ffa5c',
counter: r.row('counter').add(1).default(0)
}, {conflict: "update"})
but it dies with "RqlCompileError: r.row is not defined in this context in"
Any help / guidance is appreciated, thanks!
source
share