I have a collection in MongoDB called Results
I have a field in the collection called Positions
"Positions": {
"X": "1",
"Y": "2"
}
I want to update this field to be an array of positions
"Positions": [{
"X": "1",
"Y": "2"}, {X:"100", Y:"200"}]
I want to do this using the command line, is it possible? I have tried the following
use MyMongoDb
followed by
db.getCollection("Results").find( { "Positions" : { $type : 2 } } ).snapshot().forEach( function (x) {x.Positions = [ Positions ];db.jobs.save(x);});
I get an exception
QUERY [js] uncaught exception: TypeError: db.getCollection(...).find(...).snapshot is not a function : @(shell):1:1