dynamo icon indicating copy to clipboard operation
dynamo copied to clipboard

Support OR & AND within condition expression.

Open fogfish opened this issue 1 year ago • 1 comments

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)),
)

fogfish avatar Mar 24 '24 19:03 fogfish

Yes****

Cleanfastllc avatar Aug 02 '24 18:08 Cleanfastllc