This is likely going to be the last version that supports mongoose < 6.8.
- Define explicit entry points via
exports
and avoid using non-standardmodule
field. - Clarify that
mongoose
>=6.8 versions are not supported due to the breaking change that removed the first generic parameter ofSchemaOptions
type. - Correctly handle nullable fields (fixes #3).
- Do not create manually corresponding fields in a schema with
createdAt
/updatedAt
fields generator as it causes a error upon saving an existing document in astrict: 'throw'
mode.
- Added the ability to opt out of zod prototype extension and set the default
toMongooseSchema
options insetup
function.
- When using
.lean()
, for fields ofBuffer
type an actualBuffer
instance is returned instead ofBinary
. - Prevent
mongoose-lean-defaults
from settingundefined
to the missing fields. - Merge type options set multiple times with
.mongooseTypeOptions()
. - Make sure
genTimestampsSchema
sets the correcttimestamps
schema option in addition. - All generated mongoose schemas now have
strict
option set tothrow
. There's an option to override this behaviour for all the schemas or per a schema basis.
- Fixed an erroneous sub schema validation error if one of its fields has
Buffer
type.
- Fix the issue resulting in fields with custom types set via
mongooseZodCustomType
still havingMixed
type in the resulting schema. - Fields assigned a
Buffer
mongoose type now have a nativeBuffer
TypeScript type.
- Fix ESM & DTS outputs.
- Add type-safe alternatives for
validate
/required
type options:mzValidate
andmzRequired
. - Set
minimize: false
in schema options by default. - Detect if the following plugins are installed and automatically register them on created schemas:
mongoose-lean-virtuals
,mongoose-lean-defaults
,mongoose-lean-getters
. - Set
virtuals: true
,defaults: true
andgetters: true
automatically when using.lean()
query method if respective plugins are installed as well asversionKey: false
.
- Throw an error upon schema generation if zod's
.optional()
is used but mongoose'srequired
set to true or vice versa. - Switch to using native mongoose types for number/string/boolean/date with value casting disabled to fix type specific operators not recognized by mongoose.
Initial release.