Closed fushugaku closed 3 months ago
I roughly got it working like this, however I'm not sure if it is typesafe
export function zodSchema<T extends ZodRawShape>(
schema: ZodObject<T>,
options?: SchemaOptions<FlatRecord<any>, {}, {}, {}, {}, any>
): Schema<z.infer<typeof schema>> {
const definition = parseObject(schema);
return new Schema<z.infer<typeof schema>>(definition, options);
}
SchemaOptions and FlatRecord come from 'mongoose' library
Will be in next release
With mongoose you can define timestamps like this const userSchema = new Schema({ name: String }, { timestamps: true });
how can you do it when using this library?