Transaction was aborted due to detection of concurrent modification
I have tried searching for this and what to do, but have not seen anything.
There are no ‘unique’ indexes involved here. Should I be doing something at application level to avoid concurrent writes?
The query in question:
await this.client.query(
q.Let(
{
logMeta: q.Select(['ref'], q.Get(
q.Documents(q.Collection('log_meta')),
)),
doc: q.Match(
q.Index('action_by_id'),
[id]
),
},
q.If(
q.Exists(q.Var('doc')),
q.Abort('That ID already exists'),
q.Do([
q.Update(
q.Var('logMeta'),
{
data: {
last_added: q.Add(q.Select(
['data', 'last_added'],
q.Get(q.Var('logMeta'))
), 1)
}
}
),
q.Create(
q.Collection('actions'),
{ data: entry }
),
])
)
)
)