Update each piece of data in mongodb

refer to

http://www.cnblogs.com/time-is-life/p/5489770.html

 

The latitude and longitude of the loc field of the original data structure stores the dimension first, then the precision, and updates it to the first precision and the latter dimension

 

db.customerLocation.find({"loc.lat": { $exists: true }}).forEach(function (doc) {

 

    var oldlat = doc.loc.lat;

    var oldlng = doc.loc.lng;

    db.customerLocation.update({_id: doc._id}, { $set: {"loc": {

        "lng" : oldlng,

        "lat": oldlat

    } } });

    

})

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326167221&siteId=291194637