我想要的是,每3天运行一次猫鼬查询以注销所有已登录的用户。
架构
const LoginLogsSchema = new Schema({
ip: String,
user: { type: Schema.Types.ObjectId, ref: "User" },
status: Boolean,
timeLogin: { type: Date, default: Date.now() },
timeLogout: Date
});
方法1
使用setInterval
每隔259200000
秒运行一次(3天之内的军事)。如果timeLogin
和new Date()
之差为259200000
,则注销
这似乎是一种幼稚的方法,我想要一种有效的方法。