atomic method in mongoDB using node: find object, create if nonexistant

94 viewsfindmongodbnode.jsfind mongodb node.js
0

im having issues finding an atomic method for finding a single object in MongoDB and creating it with some preset values if it doesn’t exist yet.
I found a thread (MongoDB atomic "findOrCreate": findOne, insert if nonexistent, but do not update) but the method findAndModify is deprecated and it seems to me that findOneAndUpdate always updates the object, therefore resetting all my data when an object is found, rather than just returning the found one without changing it.

Thanks in advance, i’ve searched a lot but didn’t find anything that helped me.