irc_dicom_service/app/model/config.js

44 lines
866 B
JavaScript

/**
* 配置表
*/
module.exports = app => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
const ConfigSchema = new Schema({
ip: 'string',
port: 'string',
aet: 'string',
region: 'string',
accessKeyId: 'string',
accessKeySecret: 'string',
bucket: 'string',
basePath: 'string',
eiscPath: 'string',
pacsPath: 'string',
ossPacsPath: 'string',
meta: {
createdAt: {
type: Date,
default: new Date()
},
updatedAt: {
type: Date,
default: new Date()
}
}
});
ConfigSchema.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("Config", ConfigSchema);
};