简体   繁体   English

使用$ set更新mongo集合

[英]Update mongo collection with $set

Trying to update a collection and getting invalid syntax from '$'. 尝试更新集合并从'$'获取无效语法。 This script works correctly inside robomongo GUI but not from the terminal..? 这个脚本在robomongo GUI中正常工作,但不是从终端..? Probably something simple but I can't seem to figure out why it's giving an error. 可能是一些简单的东西,但我似乎无法弄清楚为什么它会给出一个错误。

    collection.update({'title': "Super excited"},{ $set: {"fb_count": 300}}, {multi: true})

try following code, and I think you can specify multi as argument 尝试下面的代码,我认为你可以指定multi作为参数

collection.update({'title': "Super excited"}, {'$set': {"fb_count": 300}}, multi=True)

pleaser refer to pymongo.collection.Collection.update 请参考pymongo.collection.Collection.update

你错过了"$set" (和"multi" )的引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM