mongodb - mongo 在 $and 中使用 $match
问题描述
我试图在 $match 中使用 $and ,但似乎无法正确使用。我使用的语法不正确。
{
"$match":
{
"$expr": {
"$and": [
{
"$match": {
"contra": {
"$exists": true
}
}
}
,
{
"$match": {
"$expr": {
"$eq": [
"$isActivation", true
]
}
}
}
]
}
}
}
解决方案
应该像这样简单:
{
"$match": {
"contractId": { "$exists": true },
"isActive": true
}
}
推荐阅读
- php - PHP 日历的问题
- reactjs - 使用 React + Material UI Card Expander 扩展单个卡片
- python - Python - 计算一个条件后开始的值的平均值(例如,在另一列中的第一个非零之后)
- compilation - 如何在 Fedora 上为 openwrt 编译和运行二进制文件?
- http-headers - 角度 5 和 8 - 431 请求标头字段太大
- php - 防止 DDoS 和 Web 服务器中断
- c++ - “缺少类型说明符 - 假定为 int”无法通过在主函数中添加“return 0”来解决
- javascript - Vuetify 网格系统行管理
- python - 我如何为 for 循环中的不同数据集调用 model.fit()?
- r - 我想计算一个人在某个日期的年龄并将其作为一个单独的变量呈现