I\'d like to have a single method that either creates or updates a document for a policy. Searching and trying different techniques like this one, I have come up with a nul
This could be useful (from the docs):
If you specify an _id field in either the query parameter or replacement document, MongoDB uses that _id field in the inserted document.
So when you write:
model.findOneAndUpdate({_id: id}, data, f);
And id is null, it will insert a document with null as id.
id
null