feat: inform

This commit is contained in:
archer
2023-06-06 22:07:55 +08:00
parent 941549ff04
commit 55d0ed9de6
22 changed files with 561 additions and 102 deletions

View File

@@ -0,0 +1,40 @@
import { Schema, model, models, Model } from 'mongoose';
import { informSchema } from '@/types/mongoSchema';
import { InformTypeMap } from '@/constants/user';
const InformSchema = new Schema({
userId: {
type: Schema.Types.ObjectId,
ref: 'user',
required: true
},
time: {
type: Date,
default: () => new Date()
},
type: {
type: String,
enum: Object.keys(InformTypeMap)
},
title: {
type: String,
required: true
},
content: {
type: String,
required: true
},
read: {
type: Boolean,
default: false
}
});
try {
InformSchema.index({ time: -1 });
InformSchema.index({ userId: 1 });
} catch (error) {
console.log(error);
}
export const Inform: Model<informSchema> = models['inform'] || model('inform', InformSchema);

View File

@@ -68,3 +68,4 @@ export * from './models/promotionRecord';
export * from './models/collection';
export * from './models/shareChat';
export * from './models/kb';
export * from './models/inform';