Replace a document in the collection according to the specified arguments.
The id of the provided document is not used, in order to avoid updated id error.
You may have to use UpdateResult.getUpsertedId in order to retrieve the generated id.
Save the document.
If the document has no id field, or if the document has a null id value, insert the document.
Otherwise, call replaceOneById with upsert true.