How do I create a document with an ID only if it doesn't exist, atomically? If it already exists, I would like it to callback (with the knowledge that it exists) and delete that document.
A naive find and check on the application layer seems to have room for failure.
Ex: I have a document
{_id: "Alice"}
If the document is already in the collection then delete the document. If the document is not in the collection then insert into the collection.