MongoDB updating fields in nested array

后端 未结 3 2076
庸人自扰
庸人自扰 2020-12-06 13:46

MongoDB updating fields in nested array

How can I set \"play\" to \"play photo\" in the photos array?

I only know its _id.

\"_id\": ObjectId(         


        
3条回答
  •  有刺的猬
    2020-12-06 14:08

    You can't. The positional operator is only available for the first array in your document hierarchy. As such you cannot manipulate individual elements of deeper nester arrays.

    It's a known issue and is scheduled for development here : https://jira.mongodb.org/browse/SERVER-831

    Until that time you'll have to normalize your schema a bit I'm afraid.

提交回复
热议问题