我试图使用python更新MongoDB上的数据,但发现了一个错误。我已经按照文档说明了如何实现它,但是错误仍然存在。有人能帮我修一下吗?你知道吗
@app.route('/updateData', methods=['POST'])
def updateData():
dataList = mongo.db.warehouse
old_Data = {
"name": "Pulo Gebang Warehouse"
}
new_Data = {
'$push':{"racks":{"rack columns":{"rack objects":{"items":{'$each':[{"index":4, "item":{"SKU": "HD 2179/3",
"arrivalDate": "2019-10-22",
"brand": "Philips",
"maxQty": 30,
"name": "Playstatus 10",
"qty": 10}}]}}}}}
}
dataList.update(old_Data, new_Data)
return "Update Success!"
这是我的数据库
[
{
"floorRacks": [
{
"adjacentRackID": "A1",
"floorColumn": [
{
"floorObjects": [
{
"index": 0,
"item": {
"SKU": "HD 1179/3",
"arrivalDate": "2019-10-22",
"brand": "Philips",
"maxQty": 30,
"name": "Blender Super mewah",
"qty": 10
}
},
{
"index": 1,
"item": "null"
}
],
"index": 0
}
]
}
],
"name": "Pulo Gebang Warehouse",
"racks": [
{
"code": "A",
"rack_columns": [
{
"columnID": 0,
"rack_objects": [
{
"items": [
{
"index": 0,
"item": {
"SKU": "HD 1179/3",
"arrivalDate": "2019-10-22",
"brand": "Philips",
"maxQty": 30,
"name": "Blender Super mewah",
"qty": 10
}
},
{
"index": 1,
"item": {
"SKU": "HD 1179/3",
"arrivalDate": "2019-10-22",
"brand": "Philips",
"maxQty": 30,
"name": "Blender Super mewah",
"qty": 10
}
},
{
"index": 2,
"item": "null"
},
{
"index": 3,
"item": {
"SKU": "HD 1189/3",
"arrivalDate": "2019-10-22",
"brand": "Philips",
"maxQty": 35,
"name": "Blender Super mewah Eksklusif",
"qty": 10
}
}
],
"level": 0
}
]
}
]
}
]
}
]
下面是完整的错误信息
pymongo.errors.WriteError: The dollar ($) prefixed field '$each' in 'racks..rack columns.rack objects.items.$each' is not valid for storage.
尝试将查询更改为以下内容:
相关问题 更多 >
编程相关推荐