Reputation: 443
Suppose I have multiple instances of an app reading a single row with a query like the following
r.db('main').
table('Proxy').
filter(r.row('Country').eq('es').and(r.row('Reserved').eq(false))).
min(r.row('LastRequestTimeMS'))
the 'Reserved'
field is a bool
I want to guarantee that the same instance that have read that value do an update to set the 'Reserved'
value to true
to prevent other instances from reading it
can someone please point me to how I can make this guarantee?
Upvotes: 1
Views: 22
Reputation: 5289
Generally the way you want to do something like this is you want to issue a conditional update
instead, and look at the returned changes to get the read. Something like document.update(function(row) { return r.branch(row('Reserved'), r.error('reserved'), {Reserved: true}); }, {returnChanges: true})
.
Upvotes: 1