OpenKitten / Meow

MongoDB object persistence for Swift
MIT License
66 stars 3 forks source link

Ability to partial update an object #2

Closed kimdv closed 7 years ago

kimdv commented 7 years ago

A partial update for a document so that can be used with the PATCH request. It is also more bandwidth friendly if MongoDB is hosted externally.

Joannis commented 7 years ago

Shouldn't be difficult to implement. MongoDB has the $set operator which perfectly aligns with this.

Obbut commented 7 years ago

I already implemented this last week. I'll update the docs soon, but in short: Meow generates a Values struct that represents partial values of a model. Currently you can myModel.update(with: partialValues.serialize()) but this will be more seamless in the future.

You can see how I handle PATCH requests in MeowVapor here: https://github.com/OpenKitten/MeowVapor/blob/master/Sources/MeowVapor/ModelController.swift#L64