jacksontj / dataman

MIT License
9 stars 4 forks source link

Option for set() or update() to replace the stored record with the sent record #46

Closed kahuang closed 6 years ago

kahuang commented 6 years ago

Right now set/update will update the fields specified in the record in the request

It would be nice to have a feature/flag to replace the stored record entirely with the record in the request to mirror the mongodb behavior (https://docs.mongodb.com/manual/reference/method/db.collection.update/#replace-a-document-entirely)

jacksontj commented 6 years ago

From my initial thinking this would fit better with set() (since we don't want to update N records to be identical to one sent, since we'd get pkey conflicts all over). I'll take a look at it this week. Right now the Set() is translating to an update under-the-hood, but it would just need to set the other fields (the ones not present in the API call) to nil.

kahuang commented 6 years ago

perfect, mongo doesn't allow blanket updates() with doc replacement anyway so that'll bring feature parity for updates