first commit
This commit is contained in:
18
apps/backend/src/models/budget.model.ts
Normal file
18
apps/backend/src/models/budget.model.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import mongoose, { type InferSchemaType } from 'mongoose';
|
||||
|
||||
const budgetSchema = new mongoose.Schema(
|
||||
{
|
||||
category: { type: String, required: true },
|
||||
amount: { type: Number, required: true, min: 0 },
|
||||
currency: { type: String, default: 'CNY' },
|
||||
period: { type: String, enum: ['monthly', 'weekly'], default: 'monthly' },
|
||||
threshold: { type: Number, min: 0, max: 1, default: 0.8 },
|
||||
usage: { type: Number, min: 0, default: 0 },
|
||||
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: false }
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export type BudgetDocument = InferSchemaType<typeof budgetSchema>;
|
||||
|
||||
export const BudgetModel = mongoose.models.Budget ?? mongoose.model('Budget', budgetSchema);
|
||||
Reference in New Issue
Block a user