* feat: log store

* fix: full text search match query

* perf: mongo schema import, Avoid duplicate import
This commit is contained in:
Archer
2024-07-05 17:37:42 +08:00
committed by GitHub
parent 88d10451c9
commit 5605f1a892
39 changed files with 252 additions and 201 deletions

View File

@@ -0,0 +1,27 @@
import { getMongoModel, Schema } from '../../../common/mongo';
import { SystemLogType } from './type';
import { LogLevelEnum } from './constant';
export const LogCollectionName = 'system_logs';
const SystemLogSchema = new Schema({
text: {
type: String,
required: true
},
level: {
type: String,
required: true,
enum: Object.values(LogLevelEnum)
},
time: {
type: Date,
default: () => new Date()
},
metadata: Object
});
SystemLogSchema.index({ time: 1 }, { expires: '15d' });
SystemLogSchema.index({ level: 1 });
export const MongoLog = getMongoModel<SystemLogType>(LogCollectionName, SystemLogSchema);