Closed dmchoiboi closed 9 months ago
Parser is throwing errors when parsing schemas that use mongoose.Schema.Types.* as a types.
mongoose.Schema.Types.*
This change updates the parser to handle schemas defined like
const addressSchema = new mongoose.Schema( { city: { type: mongoose.Schema.Types.String, required: true, }, coordinates: [{ lat: Number, long: Number }] }, { _id: false } ); const anotherSchema = new mongoose.Schema( { info: { type: mongoose.Schema.Types.String, required: true, }, creator: String, time: Number } ); const User2Schema: User2Schema = new mongoose.Schema( { _id: { type: mongoose.Schema.Types.Number, required: true, }, address: { type: addressSchema, // this test ensures the required property here is projected properly by `processChild` in `src/helpers/parser.ts` required: true, }, lastOnlineAt: Date, // Testing https://github.com/francescov1/mongoose-tsgen/issues/114 anArrayOfSchemasWithArrayDocuments: [addressSchema], // Testing schema maps aMapOfSchemas: { type: Map, of: anotherSchema, required: true }, aMapOfSchemaArrays: { type: Map, of: [anotherSchema] }, anArrayOfSchemaMaps: [ { type: Map, of: anotherSchema } ] }, { timestamps: true, } );
Great add, thanks for the PR @dmchoiboi!
Live in version 9.2.10 🚀
Parser is throwing errors when parsing schemas that use
mongoose.Schema.Types.*
as a types.This change updates the parser to handle schemas defined like