【发布时间】:2021-08-01 23:11:51
【问题描述】:
我有一个看起来像这样的文档:
{
_id: "....",
hostname: "mysite.com",
text: [
{
source: "this is text. this is some pattern",
...
},
{
source: "....",
...
}
]
}
我正在尝试从text 数组中删除与我的查询中的特定条件匹配的项目:
db.getCollection('TM').updateMany(
{hostname: "mysite.com"},
{
$pull: {
"text.source": /this is some pattern/
}
},
{ multi: true }
)
这里我想从数组中删除source 中的值与this is some pattern 匹配的所有项目。当我执行这个查询时,它给出了一个错误提示:Cannot use the part (source) of (text.source) to traverse the element with error code 28。
实现这一点的方法是什么?
【问题讨论】:
标签: string mongodb mongoose nosql