I'm iterating on a query results computing an array of float values. Now from C++ I want to add it to the originating record, or, if already present, update it.
From Javascript I do something similar to:
db.scraps.find({type: {$exists: 0}}).forEach(function (doc) {
var new_array = []
// fill the elements of new_array from doc fields
doc.new_field = new_array;
db.scraps.save(doc);
}
Seems that this cannot be done with the C++ driver (I'm still running 2.6) except using update
. If true, I think I should have to save in an array the pair (OID, new_array) from my query and then iterating on it calling: conn.update("kb.scraps", QUERY("_id" << OID), BSON("new_field" << new_array))
Thanks for your help!