I want to create a virtual 'passed' value of a schema to do so I need to check another schema to see if two values match.
had a look online and you can populate the ref during a query but haven't seen any examples of doing it directly in a schema
var ExerciseSchema = new Schema({
title: { type: String, required: true },
output: [{ type: String, required: true }]
});
export var Exercise = mongoose.model('Exercise', ExerciseSchema);
I want to compare the output of the ExerciseSchema with the output from AttemptSchema and return true or false using the virtual 'passed' variable
var AttemptSchema = new Schema({
exercise: { type: ObjectId, ref: 'Exercise', required: true },
output: [{ type: String }],
});
export var Attempt = mongoose.model('Attempt', AttemptSchema);
AttemptSchema.virtual('passed').get(function() {
// compare outputs to see if passed
});