Source Doc
{
"_id" : "12345",
"LastName" : "Smith",
"FirstName" : "Fred",
"ProfileCreated" : NumberLong(1447118831860),
"DropOut" : false,
}
new document
{
"_id" : "12345",
"LastName" : "Smith",
"FirstName" : "Fred",
"ProfileCreated" : NumberLong(1447118831860),
"DropOut" : true,
"LatestConsultation" : false,
}
I have two collections that contain many identical identifiers and document fields, but over time, new documents will be added to them, and new documents will be created with a new identifier.
I think I know how to process new documents with $setOnInsertand upsert = true, but I'm not sure how best to handle adding new fields. The behavior that I require for documents that exist in a collection that is mapped to _idnew fields is to add a new field to the document without changing the values of any of the other fields, even if they were changed, as in the example where it DropOutchanged. As a result, I need a document.
Results Document
{
"_id" : "12345",
"LastName" : "Smith",
"FirstName" : "Fred",
"ProfileCreated" : NumberLong(1447118831860),
"DropOut" : false,
"LatestConsultation" : false,
}
? , - , , , , : -)
PS. Pymongo, Pymongo , mongo.