express-restify-mongoose
express-restify-mongoose copied to clipboard
upsert function (update if exists and insert if doesn’t exists)
Hello, I want to develop upsert (update if exists and insert if doesn’t exists) function with the methods from express-restify-mongoose which works on server side. Any hints are welcome.
In general what is missing to me is documentation by examples.
Thanks in advance.
When working through an API, you usually know if an object exists or not. Do you have a particular use-case for upsert?
Indeed, we are a bit lacking in examples, this is definitely an area that needs work!
The use case is when you want to store user settings or user preferences. In most of the cases you simply want to store the actual data and don't care if have been exist or not until that moment. In this case upsert function is most convenient for the developer.
Fair enough. The best I can offer you at the moment is to create defaults when said user signs up and then you don't have to worry about upserting.