node.js - 猫鼬中的交叉表查询
问题描述
我有 2 个架构teamSchema
, teamAllocationSchema
这里 teamAllocationSchema
指的是teamSchema
.
我想从中获取所有记录teamAllocationSchema
,其中所有记录team_id
都有真实的文档teamSchema
。
无法弄清楚如何为此创建聚合管道,请帮助。
const teamSchema = new Schema({
project_id: {
},
team_name: {
type: String,
required: [true]
},
description: {
type: String
},
status: {
type: Boolean
}
}, { timestamps: true });
const teamAllocationSchema = new Schema({
project_id: {
type: Schema.ObjectId,
ref: projectModel
},
team_id: {
type: Schema.ObjectId,
ref: teamSchema
},
member_id: [{ type: ObjectId, ref: userModel }],
}, { timestamps: true
解决方案
推荐阅读
- vue.js - 使计算的 Vue 属性依赖于当前时间?
- python-3.x - 使用 python 更改 .txt 文件中的字符,根据它们的频率
- java - 在要求用户按 1 继续后,如何让我的程序再次运行?
- javascript - javascript || Angular2/6:多次调用 setInterval 但最后一个 timerId 没有停止,即使 clearInterval 调用
- twitter-bootstrap - 单击时隐藏 Bootstrap 折叠按钮
- node.js - 如何让函数等到我在 node.js 中得到响应
- javascript - RxJS 6 缓冲区与 debounce 作为closureNotifier
- python - 使用 Java 进行 RSA 加密的字符串在使用 Python 解密时包含额外的加密字符
- css - CSS。在引导按钮内中断文本
- r - 有条件地从缓冲区中的栅格中提取