mongo 在 $and 中使用 $match
mongo Using a $match within an $and
我正在尝试在 $match 中使用 $and,但似乎无法正确使用。我使用的语法不正确。
{
"$match":
{
"$expr": {
"$and": [
{
"$match": {
"contra": {
"$exists": true
}
}
}
,
{
"$match": {
"$expr": {
"$eq": [
"$isActivation", true
]
}
}
}
]
}
}
}
应该这么简单:
{
"$match": {
"contractId": { "$exists": true },
"isActive": true
}
}
我正在尝试在 $match 中使用 $and,但似乎无法正确使用。我使用的语法不正确。
{
"$match":
{
"$expr": {
"$and": [
{
"$match": {
"contra": {
"$exists": true
}
}
}
,
{
"$match": {
"$expr": {
"$eq": [
"$isActivation", true
]
}
}
}
]
}
}
}
应该这么简单:
{
"$match": {
"contractId": { "$exists": true },
"isActive": true
}
}