Mongodb结合了查找和更新

时间:2017-05-20 14:11:01

标签: mongodb lookup

是否可以根据查找值更新数据库?

pipeline = [
{'$limit': 10000}, # to limit query for testing purpose
{'$lookup':  # left join of user_cities DB
     {'from': 'weather_mapping',
      'localField': 'cityId',
      'foreignField': 'id',
      'as': 'mapping'}
 },
{'$lookup':  # left join of user_cities DB
     {'from': 'weather',
      'localField': 'mapping.okato',
      'foreignField': 'okato',
      'as': 'weahter'}
 }, ]
{'$out': 'activity_weather'}  #HERE I WOULD LIKE TO UPDATE THE ORIGINAL DOCUMENT RATHER THAN GENERATING A NEW ONE
db['activity'].aggregate(pipeline, allowDiskUse=True)

是否可以包含更新命令而不是' $ out'反之亦然在更新命令中放入$ lookup?

0 个答案:

没有答案