更新MongoDB中的数组元素
我正在尝试更新文档中的数组元素而不更改整个数组。
数组元素看起来像这样
假设我只需要更新索引1
元素的值。为此,我有:
的_id
索引
1
的值- ) 1650025534589.jpeg“)。
我认为MongoDB的arrayfilters
可以对其进行更新,但我无法正确获取文档。 您的帮助将不胜感激。
I am trying to update an array element inside a document without changing whole array.
Array elements look like this
Suppose i have to only update index 1
element's value. For that i have:
_id
of the documentindex
1
's value ("optionalImages-624476a7bd4d2bfe6bf86e9a-1-1650025533684.jpeg")to be updated value ("optionalImages-624476a7bd4d2bfe6bf86e9a-1-1650025534589.jpeg").
I think it can be updated by mongodb's arrayfilters
but i don't get the documentation correctly.
Your help will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QUERY1
$ [M]
在路径内指定我们要更改(而不是20和100,将您的“ .... jpg”字符串放置)
query2
Playmongo
Query1
$[m]
inside the path to specify the member value that we want to change(instead of 20 and 100, put your "....jpg" strings)
Playmongo
Query2
Playmongo