Closed DigitalVortex92 closed 1 year ago
I'm unable to repro, the following script works fine:
const mongoose = require('mongoose');
const mongooseAutoPopulate = require('mongoose-autopopulate');
const testSchema = new mongoose.Schema({
Time: Number,
}, { discriminatorKey: 'Type', _id: false });
testSchema.discriminator('SomeText', new mongoose.Schema({
SomeField: Number
}));
testSchema.plugin(mongooseAutoPopulate);
console.log('done');
Do you have some sort of polyfill for WeakMaps? What does new WeakMap()
return in your environment?
Fixed in v1.0.1 along with #113
When attempting to call
Schema.plugin(<mongoose-autopopulate here>)
, the code fails at line 225 of the index.js. Based on the section it's in, it looks like it's relevant to the change made for 0.17.1 regarding recursive schemas.Digging into the file, it seems either an intentional passing of
schemaStack
was left out of the call toeachPathRecursive
on line240
, or it was left out by accident.Not really sure to be honest as I haven't looked to much into it. I can simply add the passing of
schemaStack
as a parameter to that call to fix the issue, but I'm not sure if that defeats the purpose of the recursive fix.Edit: Apparently it has to do with the fact that I am using discriminators. I'm blind and can't read the code I'm reporting an issue with apparently :)
I'm not able to paste my direct code here, but essentially: