mongodb - PyMongo is deleting instead of updating document -


i'm using mongodb maintain list of broadcast locations , geolocation of antennas.

i'm using pymongo push locations array [{lat: nnn.dd, lon: nnn.dd}, {lat: nnn.dd, lon: nnn.dd}]

i'm reading file of location data. update looks this:

stations.update(     {"facility-id": fac_id},     {"$push": {"antennas": {"lat": lat, "lon": lon}}} ) 

the first time update runs on given facility id indeed update document in database correctly. second update same facility id deletes document entirely.

why happen? want add new coordinates antennas array.

note, duplicate geocoordinates ok.

per comments here program. run once , existing document updated. run again , document deleted:

from pymongo import mongoclient client = mongoclient()  dbname="test" db = client[dbname] stations = db.stations lat=456.45 lon=-321.90 fac="2" stations.update(     {"facility-id": fac},     {"$push": {"antennas": {"lat": lat, "lon": lon}}} )  print 'done' 


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -