selectel / mongoDB-haskell

MongoDB driver for Haskell
http://hackage.haskell.org/package/mongoDB
Apache License 2.0
21 stars 11 forks source link

Database.MongoDB.Query doesn't expose MongoDB's full update functionality #3

Open mkscrg opened 11 years ago

mkscrg commented 11 years ago

Database.MongoDB.Query doesn't expose the full power of mongo's update call. Here are a couple specific issues (not intended as a comprehensive list):

The rest of the module does a good job of mirroring mongo's query API without restricting its use. So the update functions seem out of place, in that they sacrifice "advanced" usage in favor of several predetermined modes of operation.

I haven't dug into this very much, but it seems like you could just expose update (a private function in the Query module). The convenience functions (save, replace, repsert, etc.) could remain as such or be deprecated.

superbobry commented 11 years ago

There's no way to make a call with both the MultiUpdate and Upsert flags.

What is the semantics of calling update with both these flags? Upsert means insert the document if there's nothing to update, while MultiUpdate updates 1+ existing documents. I think a more transparent way of achieving the behaviour you aim for is making two separate calls.

gregwebs commented 10 years ago

I think the driver should expose an unrestricted interface (that it is possible for a user to shoot themselves in the foot with) in addition to a higher-level/safer interface for advanced use cases