I have a collection named Price in MongoDB database, with the fields price, shopLng,shopLat and geoDist. I want, for all the documents of this collection, to update the geoDist field, depending on the shopLat and shopLng fields. The variables geoLat and geoLng are known. I tried that:
await Price.find().snapshot().forEach(function(doc) {
latmy = doc.shopLat; //tou ekastote shop
lngmy = doc.shopLng;
doc.geoDist = latmy + lngmy +geoLat + geoLng;
doc.save();
});
But if run the code showed above, that is supposed to do the job for all the documents, there must be a problem, because I get this error: TypeError: Price.find(...).forEach is not a function