如何解决通过 pymongo 重命名 DocumentDB 中数组中的字段
我在 AWS 中使用 docudmentDB(版本 3.6)。我在 AWS 中使用 python lambda 来完成这项任务。任务是重命名数组中的字段。这是我拥有的示例 JSON 文档。这里我需要将“版本”重命名为“标签”。
{
"_id": "93ee62b2-4a1f-478f-a716-b4e2f435f27d","egrouping": [
{
"type": "Video","language_code": "eng","hierarchy": {
"pype": {
"parent": "episode","version": "1","uuid": "933433-4a1f-478f-a716-b4e2f435f27d"
}
}
},{
"type": "Captions","uuid": "943454-4a1f-478f-a716-b4e2f435f27d"
}
}
}
]
}
以下代码片段我试图重命名出错的“版本”字段:
collection.aggregate([
{
'$project': {
'egrouping': {
'$map': {
"input": "$egrouping",'as': "egroup",'in': {
"hierarchy.pype.label": "$$egroup.hierarchy.pype.version"
}
}
}
}
}
])
但我最终遇到了这个错误:
"errorMessage": "Aggregation project operator not supported: '$map'",
解决方法
Amazon DocumentDB 不支持 $map。有关 DocumentDB 支持的 API 的完整列表,请参阅 https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis.html。
我们一直在从客户希望使用的 API 中倒退。您可以在此处关注我们未来的发布https://aws.amazon.com/documentdb/resources/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。