Marc, Thanks for the reply. Curious behavior with the workaround
though. The exception is no longer thrown (yea!), but the
document returned is empty. I was expecting the new, inserted
document.
There are no errors in the server log and all the upserts are
persisted, as expected.
> db.coll1.findAndModify({ "query" : { "_id" : "asdf" }, "update" : { "name" : "Object 6", "someProp" : "6" }, "upsert" : true, "new" : true } );
{
"_id" : ObjectId("4ea9309266ac51d939de73b7"),
"name" : "Object 6",
"someProp" : "6"
}
> db.coll1.findAndModify({ "query" : { "_id" : "asdf" }, "update" : { "_id" : 7, "name" : "Object 7", "someProp" : "7" }, "upsert" : true, "new" : true } );
{ }
> db.coll1.find();
{ "_id" : ObjectId("4e901e87d6d170982fc87ee1"), "name" : "Object 1",
"someProp" : "Property Value for 1" }
{ "_id" : ObjectId("4e901f30d6d170982fc87ee2"), "name" : "Object 2",
"someProp" : "Property Value for 2" }
{ "_id" : ObjectId("4ea84bbc66ac51d939de73b3"), "name" : "Object 3",
"someProp" : "3" }
{ "_id" : 4, "name" : "Object 4", "someProp" : "4" }
{ "_id" : 5, "name" : "Object 5", "someProp" : "5" }
{ "_id" : ObjectId("4ea9306066ac51d939de73b6"), "name" : "Object 5",
"someProp" : "5" }
{ "_id" : ObjectId("4ea9309266ac51d939de73b7"), "name" : "Object 6",
"someProp" : "6" }
{ "_id" : 7, "name" : "Object 7", "someProp" : "7" }