diff --git a/server/src/models/event.js b/server/src/models/event.js index 7c28d7dfc..7f1b430b4 100644 --- a/server/src/models/event.js +++ b/server/src/models/event.js @@ -26,7 +26,9 @@ const eventSchema = new Schema({ type: String, required: true, }, - description: String, + description: { + type: String, + }, startDatetime: { type: Number, required: true, @@ -35,11 +37,11 @@ const eventSchema = new Schema({ type: Number, required: true, }, - formula: { + formulaId: { type: ObjectId, ref: Formula.modelName, }, - plotter: { + plotterId: { type: ObjectId, ref: Plotter.modelName, }, @@ -52,7 +54,9 @@ const eventSchema = new Schema({ type: String, required: true, }, - description: String, + description: { + type: String, + }, }], prizes: [{ rank: { @@ -86,10 +90,10 @@ const eventSchema = new Schema({ }); eventSchema.pre('find', function populate() { - this.populate('formula').populate('plotter'); + this.populate('formulaId').populate('plotterId'); }); eventSchema.post('save', (doc, next) => { - doc.populate('formula').populate('plotter').execPopulate().then(() => { + doc.populate('formulaId').populate('plotterId').execPopulate().then(() => { next(); }); }); diff --git a/server/src/schema/types/Event.js b/server/src/schema/types/Event.js index ec0bf6c2b..d54ecf377 100644 --- a/server/src/schema/types/Event.js +++ b/server/src/schema/types/Event.js @@ -26,13 +26,13 @@ const EventType = new GraphQLObjectType({ formula: { type: FormulaType, resolve(parent) { - return parent.formula; + return parent.formulaId; }, }, plotter: { type: PlotterType, resolve(parent) { - return parent.plotter; + return parent.plotterId; }, }, rules: {