我正在预订系统上,我希望我的系统数据库能够在预定日期和时间过去时自动将记录属性(Booked)更新为false。 MongoDB有可能吗?
这是我当前的场所架构
const reserveSchema = new mongoose.Schema({
user: {type: Schema.ObjectId, ref: 'User'},
roomNo: {type: Schema.ObjectId, ref: 'venueSch'},
reserveDate: Date,
reserveTime : Date,
duration: Number,
purpose: String,
});
const requestSchema = new mongoose.Schema({
user: {type: Schema.ObjectId, ref: 'User'},
time: Date
});
const VenueSchema = new mongoose.Schema({
roomNo: {
type: String,
},
capacity: {
type: Number,
},
projector :{
type: Boolean,
},
Booked: {
type: Boolean,
default: false
},
requested:{
type: Boolean,
default: false
},
requests: [requestSchema],
bookings: [reserveSchema]
});