我有以下蒙戈子文档MongoDB的更新查询设置现有字段到数组
"location" : { "zipCode" : "90670", "lat" : "33.942669", "lng" : "-118.074384", "city" : "Santa Fe Springs", "state" : "California", "streetAddress" : "12131 Telegraph Road, 2nd Floor", }
有人建议我MONGO更新查询或节点功能得到以下文件
"location" : { "zipCode" : "90670", "city" : "Santa Fe Springs", "state" : "California", "streetAddress" : "12131 Telegraph Road, 2nd Floor", "geo" : { "type" : "Point", "coordinates" : [ 33.942669 ,-118.074384 ] } }
甚至你可以这样做db.collection.update({x:1},{$取消设置:{X: '',y:''},$ set:{point:{x:1,y:2}}})。 – LuisFMorales