Я пытаюсь обновить несколько полей в пределах массива в массивеUpdate несколько полей в вложенном массиве в 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
}
],
}
Я хочу, чтобы обновить массив URLS как:
urls: [
{
status: null,
domain: "wtop.com",
url: "http://t.co/hbFt7t1n",
period: null,
resolved_url: "http://wtop.com/?nid=610&sid=3162096",
annotation: null,
annotation2: "guncontrol"
}
],
Я использую что-то вроде этого, чтобы сделать обновление:
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]
Любые предложения?