{
'ID': 'IDexample',
'Coordinates' : [
{'CoordinateX' : 123,
'CoordinateY': 5
},
{'CoordinateX' : 54,
'CoordinateY': 23'
}
]
}
How can I add 2 elements to array Coordinates if "IDexample" is present in coordinatesCollection ? If not exist add new Document' to collection. I am using MongoClient and the name of the collection is coordinatesCollection.
coordinatesCollection.findOne( { "unique_id" : unique_id }, function(err, object){
if (object) {
????
} else {
coordinatesCollection.insert({
"unique_id" : unique_id,
"coordinates" : [
{"coordinateX" :msg.coordinatex,
"coordinateY" : msg.coordinatey
}
]
})
}
});