mycol = mydb["trajectory_info1"]
mydoc = mycol.find({'camera_id':data['camera_id'],'id':data['id']})
if mydoc.count()>0:
mycol.update({'camera_id':data['camera_id'],'id':data['id']},{'$addToSet':{
'lon_lat':data['lon_lat'],
'depth':data['depth'],
'pix_location':data['pix_location'],
'frame':data['frame']}})
注意,addtoset一定得是array,否则会失败
本文介绍了一种使用MongoDB更新特定ID和摄像头ID下轨迹信息的方法。通过find方法查询数据后,利用update方法结合$addToSet操作符来更新包含经纬度、深度、像素位置及帧数的数组字段。
1121

被折叠的 条评论
为什么被折叠?



