作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些以下类型的数据库-
var school= mongoose.model('School' ,{
name : { type : String, minlength : 1, trim : true },
email : { type : String, trim : true },
password : { type : String, minlength : 8, },
mobile : { type : Number, minlength : true },
address : { type : String },
description : { type : String },
student : { type : Array },
});
最佳答案
您应该首先在学校数据库中查询在学生数组字段中具有特定ID的文档。这是一个简单的查找查询,您可以在此查询学生字段的ID。它将在整个数组中搜索每个文档。
school.findOne({ student : id});
关于mongodb - 如何在mongoDB中加入数据库并获取所需结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52019370/
我是一名优秀的程序员,十分优秀!