Mongodb 一段时间
Mongodb period of time
我想在 mongodb/mongoose 方面得到一些帮助,因为我有点卡在这里。
我正在使用 MEAN 堆栈制作员工工时记录 Web 应用程序,但我不知道如何每两周在 Mongodb/Mongoose 中创建时间段。
例如开始日期:4.7,结束日期:17.7,当当前日期变为 18.7 时,它将创建新文档,开始日期:18.7,结束日期:31.7 等
我的架构目前如下(稍后我将添加更多信息):
var payPeriodSchema = new Schema ({
hoursInPayPeriod: {
type: Number,
default: 0,
required: true
},
payPeriodStartDate: {
type: Date,
required: true
},
payPeriodEndDate: {
type: Date,
required: true
},
isPaid: {
type: Boolean,
default: false,
required: true
}
}, {
timestamps: true
});
一个简单的 cronjob 就可以完成这项工作。我会把这个任务放在一个单独的项目中,与你的主节点服务器分开。
我想在 mongodb/mongoose 方面得到一些帮助,因为我有点卡在这里。
我正在使用 MEAN 堆栈制作员工工时记录 Web 应用程序,但我不知道如何每两周在 Mongodb/Mongoose 中创建时间段。
例如开始日期:4.7,结束日期:17.7,当当前日期变为 18.7 时,它将创建新文档,开始日期:18.7,结束日期:31.7 等
我的架构目前如下(稍后我将添加更多信息):
var payPeriodSchema = new Schema ({
hoursInPayPeriod: {
type: Number,
default: 0,
required: true
},
payPeriodStartDate: {
type: Date,
required: true
},
payPeriodEndDate: {
type: Date,
required: true
},
isPaid: {
type: Boolean,
default: false,
required: true
}
}, {
timestamps: true
});
一个简单的 cronjob 就可以完成这项工作。我会把这个任务放在一个单独的项目中,与你的主节点服务器分开。