在特定日期的特定时间过去之后,是否有办法更新mongodb中的记录?

时间:2019-03-28 08:58:46

标签: node.js mongodb

我正在预订系统上,我希望我的系统数据库能够在预定日期和时间过去时自动将记录属性(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]
});

0 个答案:

没有答案
相关问题