如果我具有以下架构,如何查询每个学生每年的最低访客数? 访客是访问文档中的一个文档。
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
ObjectId = Schema.ObjectId;
var visitorOfStudent = new Schema({
firstname: { type: String, required: true, unique: false },
lastname: { type: String, required: true, unique: false },
age: { type: Number, unique: false },
gender: { type: String, unique: false },
address: { type: String, unique: false },
date: { type: String, unique: false }
})
var visit = new Schema({
name: {
firstname: String,
lastname: String
},
age: Number,
gender: String,
address: String,
visitors: [visitorOfStudent]
}, {
collection: 'visitors'
}
);
const Visitors = mongoose.model("Visitors", visit);
module.exports = { Visitors }