fogfish / dynamo

Generic Golang Key/Value trait for AWS storage services
MIT License
18 stars 5 forks source link

Support OR & AND within condition expression. #101

Open fogfish opened 6 months ago

fogfish commented 6 months ago

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)),
)
Cleanfastllc commented 1 month ago

Yes****