mongodb - 如何在 mongdb 中不返回查找结果
问题描述
我想通过使用查找功能检查该帐户是否在任何订单中使用来返回帐户。但我不想返回查找结果。如何忽略/删除/排除查找结果
Account.aggregate([
{
$match: {
type: {$eq: type}
},
},
{
$lookup:
{
from: "orders",
let: {accountId: {$toString : "$_id"}},
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{$eq: ["$$accountId", "$usedAccountId"]},
{$eq: ["$orderState","COMPLETED"]
]
}
}
}
],
as: "orders"
}
}
])
通过上述查询,我得到以下结果。我想摆脱订单数组
[
{
//accountObject,
orders: [
//orderObject
]
}
]
解决方案
推荐阅读
- count - 使用 DAX 在类别中使用 maxnr 计数对象
- java - InteliJ Maven 单元测试执行类路径
- sql - 如何执行作为值存储在数据库中的 SQL 语句?
- javascript - 如何使用 jquery 或 js 将数据/值传递给选择选项?
- javascript - jquery中的一键事件处理的多个UL
- apache - 一些 htaccess 问题:为什么它不起作用?
- python-3.x - 同一个实体如何作为参数和对象起作用?
- java - 点击recyclerview时触摸事件不起作用
- python - SCD方法更新维表中记录的过程是什么
- python - Python:匹配字符串中的多个子字符串