/** * Pacs位置 */ module.exports = app => { const mongoose = app.mongoose; const Schema = mongoose.Schema; const StatusSchema = new Schema({ trialId:String, task_id: String, status:String, downloadCount: Number, downloadNum: Number, pushloadNum: Number, uploadNum: Number, meta: { createdAt: { type: Date, default: new Date() }, updatedAt: { type: Date, default: new Date() } } }) StatusSchema.pre("save", function (next) { if (this.isNew) { // 创建时间 this.meta.createdAt = this.meta.updatedAt = new Date(); } else { this.meta.updatedAt = new Date(); } next(); }); return mongoose.model("Status", StatusSchema); };