first commit

This commit is contained in:
2025-11-01 09:24:26 +08:00
commit 6516d8dc78
87 changed files with 7558 additions and 0 deletions

View 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);