{"repo":"git-zodyac/mongoose","free":true,"listed":false,"github":"https://github.com/git-zodyac/mongoose","clone":"git clone https://github.com/git-zodyac/mongoose.git","description":"Converts your Zod schemas into fully-functional Mongoose schemas","language":"TypeScript","stars":52,"topics":["adapter","mongo","mongodb","mongoose","validation","zod"],"license":null,"category":"data-pipelines","readme_excerpt":"Zod to Mongoose schema converter This package provides a function to convert zod object to mongoose schema. [!NOTE] This package is in early development stage. Please report any issues you find and please expect API to change in minor versions. Installation Breaking changes [!WARNING] If you were using zId , zUUID , z.objectId() , z.mongoUUID() before, please replace those with zId() and zUUID() . - zId is now zId(ref?) - zUUID is now zUUID() Usage First, extend Zod with extendZod , then create your zod schema: Then, convert it to mongoose schema and connect model: That's it! Now you can use your mongoose model as usual: [Note] extendZod should be called once for the whole application. Features Full support list can be found in SUPPORTED.md: - ✅ Basic types - ✅ Nested objects and schemas - ✅ Arrays - ✅ Enums (strings only) - ✅ Default values - ✅ Maps - ✅ Dates - ✅ ObjectId - ✅ ObjectId references - ✅ ZodAny as SchemaTypes.Mixed - ✅ Validation using refinement for String, Number, Date - ✅ Unique for String, Number, Date, ObjectId and UUID - ✅ Sparse for String, Number, Date, ObjectId and UUID - ⚠️ Record (Being converted to Map) - ⚠️ Unions (Not supported by mongoose, will pick first inner type) - ❗️ Intersection (not supported by mongoose) - ❗️ Set (not supported by mongoose) - ❗️ Indexes (not supported by zod) - ⏳ Regex validation (coming soon) - ⏳ instanceOf (coming soon) Checking schemas To make sure nothing is missing, you can use Schema.obj : Raw object If you want to ge","default_branch":null,"files":null,"tree":[],"storefront":"/r/git-zodyac","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/git-zodyac/mongoose/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}