231120
'use strict';
module.exports = app => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
const EventSchema = new Schema({
type: { type: String },
openid: { type: String },
data: { type: Object },
dateCreated: { type: Date },
equipment: { type: Schema.Types.ObjectId, ref: 'Equipment' },
});
EventSchema.methods.getItem1 = (_id, ctx) => {
return ctx.model.Event.findById(_id);
};
EventSchema.statics.getItem2 = (_id, ctx) => {
return ctx.model.Event.findById(_id);
};
const Event = mongoose.model('Event', EventSchema, null, { cache: false });
return Event;
};
这里的getItem1 / getItem2 方法在service中该如何调用?