feat: added models

This commit is contained in:
2023-07-04 23:42:50 -03:00
parent fe0cacf145
commit 2d0f960d49
11 changed files with 94 additions and 3 deletions

View File

@@ -0,0 +1,21 @@
import { z } from 'zod';
import { Schema, model } from 'mongoose';
import { type SpendingType } from '../types/spending';
export const SpendingSchema = z.object({
amount: z.number(),
currencyId: z.string(),
date: z.date(),
spendingCategoryId: z.string(),
userId: z.string(),
} satisfies SpendingType);
const schema = new Schema({
amount: { required: true, type: Number },
currencyId: { required: true, type: String },
date: { required: true, type: Date },
spendingCategoryId: { required: true, type: String },
userId: { required: true, type: String },
} satisfies SpendingType);
export const Spending = model('Spending', schema);