我正在尝试更新 doc_list 下的字段,该字段在 proect_list 中是使用[ mongoengine ]的嵌入式文档字段
"_id":{
"$oid":"5efae3a302449b643b2e5a06"
},
"username":"Roshan",
"project_list":[
{
"project_id":"216198",
"customername":"Gopal",
"customer_region":"IND",
"doc_list":{
"status":"Inprogress",
"date_modified":{
"$date":"2020-06-30T12:32:59.851Z"
},
"date_started":{
"$date":"2020-06-30T12:32:59.851Z"
},
"nrfu_doc_id":"",
"reference_doc_id":""
}
},
{
"project_id":"624615",
"customername":"xcisco",
"customer_region":"IND",
"doc_list":{
"status":"Completed",
"date_modified":{
"$date":"2020-06-30T12:35:06.031Z"
},
"date_started":{
"$date":"2020-06-30T12:35:06.031Z"
},
"nrfu_doc_id":"",
"reference_doc_id":""
}
}
]
}
我已经尝试过这个并在 MongoEngine 文档中尝试了很多其他示例,并且在 StackOverflow 中搜索尚未解决,请帮助我进行此更新。
users = PersonProjectCollection.objects(username="Roshan", project_list__project_id="216198").update_one(set__project_list__doc_list__S__reference_doc_id='21333')
mongoengine.errors.OperationError: Update failed (Cannot create field 'doc_list' in element {project_list: [ { project_id: "216198", customername: "Gopal",
customer_region: "IND", doc_list: { status: "Inprogress", date_modified: new Date(1593520379851), date_started: new Date(1593520379851), nrfu_doc_id: "",
reference_doc_id: "" } }, { project_id: "624615", customername: "xcisco", customer_region: "IND", doc_list: { status: "Completed", date_modified: new Date(
1593520506031), date_started: new Date(1593520506031), nrfu_doc_id: "", reference_doc_id: "" } } ]})