Skip to content

Commit a7be32a

Browse files
authored
Compatibility with mongoose 9 (#30)
This pull request updates the `mongoose` dependency to version 9.5.0 and improves compatibility with newer Mongoose schema structures in the `getArrayItem` method. These changes ensure better support for recent versions of Mongoose and enhance the handling of array item schemas. Dependency update: * Upgraded the `mongoose` package version from `^8.2.3` to `^9.5.0` in `package.json` to support the latest features and fixes. Schema compatibility improvement: * Updated the `getArrayItem` method in `src/index.js` to use `schema.caster ?? schema.embeddedSchemaType`, improving support for array schemas in newer versions of Mongoose.
2 parents 9704a12 + 07dd7e2 commit a7be32a

3 files changed

Lines changed: 49 additions & 49 deletions

File tree

‎package-lock.json‎

Lines changed: 47 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"chai": "^5.1.0",
3838
"codecov": "^3.8.3",
3939
"mocha": "^10.3.0",
40-
"mongoose": "^8.2.3",
40+
"mongoose": "^9.5.0",
4141
"rollup": "^2.79.1",
4242
"rollup-plugin-terser": "^7.0.2"
4343
},

‎src/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class MongooseDummy {
144144

145145
getArrayItem(schema, output, iteration = 0, filter = () => true) {
146146
if (schema?.schema instanceof Schema) return this.iterate(schema.schema, {}, iteration + 1, filter);
147-
const itemSchema = schema.caster;
147+
const itemSchema = schema.caster ?? schema.embeddedSchemaType;
148148
if (itemSchema instanceof Schema.Types.ObjectId) return this.evaluateObjectId(itemSchema, iteration, filter);
149149
return this.evaluateDummy(itemSchema, iteration + 1, output, filter);
150150
}

0 commit comments

Comments
 (0)