17 lines
488 B
JavaScript
17 lines
488 B
JavaScript
const mongoose = require('mongoose'),
|
|
Schema = mongoose.Schema;
|
|
|
|
const schema = new Schema({
|
|
rpt: { type: String },
|
|
user: { type: Schema.Types.ObjectId, ref: 'User', required: false },
|
|
vars: { type: Schema.Types.Mixed, default: null }
|
|
}, { timestamps: true });
|
|
|
|
if (!schema.options.toObject) schema.options.toObject = {};
|
|
schema.options.toObject.transform = function (doc, ret/*, options*/) {
|
|
ret = ret.vars;
|
|
return ret;
|
|
}
|
|
|
|
module.exports = mongoose.model('Rpt_Var', schema);
|