我正在尝试查找用户是否已申请助学金,并防止他们再次申请助学金。
用户架构:
const userSchema = new mongoose.Schema({
firstName: String,
lastName: String,
Username: String,
email: String,
isAdmin: {
type: Boolean,
default: false
}
});
应用架构:
const applicationSchema = new mongoose.Schema({
applicant:{
id: {
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String
},
createdAt:{
type: Date,
default: Date.now
},
name: String,
age: Number,
status: {
type: String,
default: "Pending"
}
});
突发方案:
var bursarySchema = new mongoose.Schema({
name: String,
applications: [{
type: mongoose.Schema.Types.ObjectId,
ref: "Application"
}],
period: String,
guidelines: String
});
是否可以通过此途径查询数据库,以了解用户是否已申请特定的助学金?