我编写了一个包含以下代码的MongoDB管道:
{
$eq: [
{
"$toLower": "HELLO"
},"hello"
]
}
这是Mongo Compass中的屏幕截图
我希望它只返回true,然后“ $ match”所有(暂时)。
最终,我将"HELLO"
换成字段名称,等等。
有人知道我为什么收到此错误吗?
$ match不接受raw aggregation expressions。而是使用$expr查询表达式在$ match中包含聚合表达式。
https://docs.mongodb.com/manual/reference/operator/aggregation/match/index.html#pipe._S_match
$expr: {
$eq: [
{
$toLower: "HELLO"
},"hello"
]
}