mongo更新数组字段_更新mongodb中嵌套数组中的几个字段(使用pymongo)
我正在嘗試更新數組內數組中的一些字段
示例文檔如下:{
id: 987654321
tweets: [
{
text: "RT @947FreshFM: A vigil will be held for #SandyHook victims at UMd. at 7pm at Nyumburu Ampitheater. @BlackTerp",
urls: [
],
id: 279718351289348100
},
{
text: "RT @WTOP: McDonnell: If you talk completely about guns, I think you're missing the point. #AskTheGov http://t.co/hbFt7t1n",
urls: [
{
status: null,
domain: null,
url: "http://t.co/hbFt7t1n",
period: null,
resolved_url: null,
annotation: null
}
],
id: 281061376275906560
}
],
}
我想將url數組更新為:
^{pr2}$
我用這樣的方法來更新:collection.update({"id":987654321, "tweets.id":281061376275906560,"tweets.urls.url":"http://t.co/hbFt7t1n"},
{"$set":{
"tweets.urls.resolved_url":"http://wtop.com/?nid=610&sid=3162096",
"tweets.urls.domain": "wtop.com",
"tweets.urls.annotation2":"guncontrol"
}}, False,False)
但是它給了我錯誤can't append to array using string field name [urls]
有什么建議嗎?在
總結
以上是生活随笔為你收集整理的mongo更新数组字段_更新mongodb中嵌套数组中的几个字段(使用pymongo)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 山东2022高考分数线公布:一段线437
- 下一篇: 2021年个税扣除方式有变化,做好一件事