mirror of
https://github.com/FranP-code/spend-ia.git
synced 2025-10-13 00:14:09 +00:00
feat: mongoose integration
This commit is contained in:
1
packages/server/schemas/index.ts
Normal file
1
packages/server/schemas/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './user';
|
||||
17
packages/server/schemas/user.ts
Normal file
17
packages/server/schemas/user.ts
Normal 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);
|
||||
Reference in New Issue
Block a user