mattinsler/com.lowereast.guiceymongo

Create an update DSL

Opened this issue · 0 comments

Lots of the power of Mongo is in the update and findAndModify functionalities. I'm getting really tired of calling update and creating all the DBObjects by hand without any kind of help. I want a DSL that knows the field is an int32 and will only allow me to set it to an int or increment it. I don't want code completion to show me the possibility of doing an increment on a string field. On array and set fields, I want to see things like push, pull, addToSet, etc. This can build on the query language from Issue 7.

Maybe something like:
collection.update(Person.Name).to("Jim")
.where(Person.Name).isEqualTo("Matt").execute()
And
collection.delete(Person.Address.State).isEqualTo(Address.State.NY)
.returnOld()
Or
collection.update(Person.Age).incrementBy(1).returnNew()

This would encapsulate update and findAndModify in one clean, clear DSL.