mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00

* fix: full text search match query * perf: mongo schema import, Avoid duplicate import * feat: mongo log store * doc * fix: sandbox outputs * perf: desc color * fix: node init * perf code * perf: chat header
30 lines
705 B
TypeScript
30 lines
705 B
TypeScript
import { getMongoModel, Schema } from '../../../common/mongo';
|
|
import { SystemLogType } from './type';
|
|
import { LogLevelEnum } from './constant';
|
|
|
|
export const LogCollectionName = 'system_logs';
|
|
|
|
export const getMongoLog = () => {
|
|
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 });
|
|
|
|
return getMongoModel<SystemLogType>(LogCollectionName, SystemLogSchema);
|
|
};
|