I\'m starting to use mongoDb and I\'m stuck with a simple use case.
Let\'s say I\'ve got a collection \'aCollection\' with entries such as this:
You don't need the aggregation feature for this. A find
, forEach
, and insert
is one potential approach:
db.aCollection.find().forEach( function(myDoc) {
myDoc.geometry = {type: "Point", coordinates: [myDoc.lat, myDoc.long]};
db.newCollection.insert(myDoc);
});
It calls an individual insert for each document, but is quick and dirty if you have a small collection.