Closed coodoo closed 8 years ago
See model docs and source code.
Unfortunately, I can not find explicit ways to delete an attribute of the model, try updateAttribute
with null, empty or undefined value.
Tried following steps, no luck.
Which database engine do you use (MySQL, Mongo, etc...) ?
Mongodb, currently the only way I know is by using $unset directly.
Mmm... it seems that you need to add this functionality to jugglingdb/mongodb-adapter
For example, to MongoDB.prototype.updateAttributes.
ah, thanks for the pointer, so this one has to be implemented in every adapter, instead of being generalized into a higher level function?
We need to ask @anatoliychakkaev @1602 about adapters. The question is "What we can to remove property from a model". Lets wait for an answer :)
It should be implemented in mongodb adapter. When value set to null it should call $unset.
On Tue, Jul 29, 2014 at 3:45 PM, Alex Baumgertner notifications@github.com wrote:
We need to ask @anatoliychakkaev @1602 about adapters. The question is "What we can to remove property from a model".
Lets wait for an answer :)
Reply to this email directly or view it on GitHub: https://github.com/1602/jugglingdb/issues/412#issuecomment-50465605
Thanks for the reply, but what about other database like MySQL? Can this be a higher level function inside the ORM itself?
In mysql this is working fine, null in js becomes null in database. I will add test for that.
Say in a User model, I accidentally put in user.foo = "bar" and saved, is there a way to remove 'foo' from the database and model itself?