Api
Deprecated
Information about deprecated features and how to migrate from older versions.
Deprecated
The following features from older versions of mongoose-zod (Mongoose 7 / Zod 3) are no longer supported or have changed in @nullix/zod-mongoose.
Function Replacements
toZodMongooseSchema()
Previously, this returned a ZodMongoose wrapper used to generate the Mongoose schema.
- Replacement: Use
toMongooseSchema()which returns a fullmongoose.Schemainstance directly, orextractMongooseDef()which returns the raw Mongoose schema definition (POJO).
mongooseZodCustomType()
This was previously used to directly define a Mongoose type on a Zod schema.
- Replacement: Use
withMongoose(z.any(), { type: mongoose.Schema.Types.YourType })or specialized helpers likezObjectId()andzBuffer().
API Changes
ZodMongoose class
The ZodMongoose class has been removed.
- Replacement: The library now uses standard Zod types with metadata stored in the
zod/v4registry. All functions are now standalone helpers.
setup({ z })
This initialization step is no longer required.
- Reason: The library uses the
zod/v4registry directly and does not modify the Zod prototype.
Prototype Extensions
Methods like .mongoose(), .mongooseTypeOptions(), and .mongooseSchemaOptions() on Zod types are deprecated.
- Replacement: Use
withMongoose(zodSchema, metadata)instead.
Features
Automatic Plugin Loading
Optional peer dependencies like mongoose-lean-* are no longer automatically attached to the generated schemas.
- Replacement: Plugins should be applied to the Mongoose schema manually using the
pluginsoption intoMongooseSchemaor theschema:createdhook.