28 lines
908 B
TypeScript
28 lines
908 B
TypeScript
import mongoose, { type InferSchemaType } from 'mongoose';
|
|
|
|
const notificationTemplateSchema = new mongoose.Schema(
|
|
{
|
|
name: { type: String },
|
|
keywords: { type: [String], default: [] },
|
|
category: { type: String },
|
|
type: { type: String, enum: ['income', 'expense'] },
|
|
amountPattern: { type: String }
|
|
},
|
|
{ _id: false }
|
|
);
|
|
|
|
const notificationChannelSchema = new mongoose.Schema(
|
|
{
|
|
packageName: { type: String, required: true, unique: true },
|
|
displayName: { type: String, required: true },
|
|
enabled: { type: Boolean, default: true },
|
|
templates: { type: [notificationTemplateSchema], default: [] }
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
export type NotificationChannelDocument = InferSchemaType<typeof notificationChannelSchema>;
|
|
|
|
export const NotificationChannelModel =
|
|
mongoose.models.NotificationChannel ?? mongoose.model('NotificationChannel', notificationChannelSchema);
|