dynamo
dynamo copied to clipboard
Support OR & AND within condition expression.
There is a common pitfall with optimistic locking when application puts item. The item might not exists or the item might be update in other thread.
The existing code might look like
item, err := db.Get(...)
if recoverNotFound(err) {
item = // New Item
new = true
}
if new {
db.Put(..., item, Field.NotExists())
} else {
db.Put(..., item, Field.Eq(item.Some))
}
It would be helpful to have ability to compose condition checks into the single expression
db.Put(..., item,
ddb.Or(Field.NotExists(), Field.Eq(item.Some)),
)
Yes****