Closed MarcusElevait closed 2 years ago
We have the following virtual defined in our schema:
AnnotationTypeSchema.virtual('instances', { ref: AnnotationType.name, localField: 'classToAnnotate', foreignField: 'classToAnnotate', match: { textField: { $exists: true } }, }).get((instances: BaseAnnotationType[]) => instances.map(instance => instance.textField));
And we're trying to execute the following query:
const items = await this.annotationTypeModel .find(searchFilter) .limit(filter.limit) .skip(filter.limit * (filter.page - 1)) .sort({ title: 1 }) .populate('instances') .lean({ virtuals: true, getters: true }) .exec();
But we get the error, that the instances is undefined and therefore the map function cannot be executed.
Don't know if the intended behavior of the Plugin should cover such cases.
You should open this issue on mongoose-lean-virtuals. This project only runs getters on schema paths.
We have the following virtual defined in our schema:
And we're trying to execute the following query:
But we get the error, that the instances is undefined and therefore the map function cannot be executed.
Don't know if the intended behavior of the Plugin should cover such cases.