feat: mongoose integration

This commit is contained in:
2023-07-04 23:06:32 -03:00
parent da3e6cb101
commit 6971eeda3c
9 changed files with 62 additions and 7 deletions

View File

@@ -0,0 +1 @@
export * from './user';

View File

@@ -0,0 +1,17 @@
import { Schema, model } from 'mongoose';
import { z } from 'zod';
import { type UserType } from '../types';
export const UserSchema = z.object({
email: z.string().email(),
name: z.string(),
password: z.string().min(8),
} satisfies UserType);
const schema = new Schema({
email: { required: true, type: String, unique: true },
name: { required: true, type: String },
password: { required: true, type: String },
} satisfies UserType);
export const User = model('User', schema);