node.js - 检索与数组中的值匹配的所有对象
问题描述
我试图获取与某个值匹配但它不起作用的所有匹配对象
这是我的 bd:
我的模型.js
var professorSchema = new schema({
nome : {type: String},
email : {type: String},
url : {type: String}
})
var aulaSchema = new schema ({
tipo : {type: String},
data : {type: String},
})
var sumarioSchema = new schema({
disciplina : {type: String},
professor : {professorSchema},
aula :[aulaSchema]
})
和我的controller.js
Sumarios.listAula = ()=>{
return Sumario.aggregate(
// Start with a $match pipeline which can take advantage of an index and limit documents processed
{ $match : {
"aula.tipo":"T"
}},
{ $unwind : "$aula" },
{ $match : {
"aula.tipo":"T"
}}
).exec()
}
我试图在控制器中执行的这个查询正在返回每个数据,而不是我想要的。我的模型有问题吗?
解决方案
推荐阅读
- mysql - 数据库中的两列并转换为字典
- typescript - 在插件文件中使用 Typescript 构建的赛普拉斯问题。每次出现错误都必须关闭并重新启动
- python - __init__() 有一个意外的关键字参数“categorical_features”,不起作用
- gitlab - .gitignore 没有忽略目录
- or-tools - Google OR-Tools:ApplyLocksToAllVehicles 中没有传递部分路线时没有解决方案,但如果您指定了部分路线,则存在解决方案
- android - 条目名称“AndroidManifest.xml”发生冲突
- php - Apache 或 PHP 未正确指定资产文件夹
- java - 如何在java中使用apache qpid库和动态证书字符串(而不是证书路径)创建amqp连接
- java - Spring boot,对不同的查询使用相同的实体
- csv - 需要帮助使用 Clojure 下载和读取内存中的压缩 CSV 文件