Saving formulaId as formulaIf instead of Formula in the Db
same for the plotters
This commit is contained in:
1 parent
f4cf5884f5
commit
3a46009042
2 files changed
+12
-8
No files matched your search
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in new issue
Block a user