-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* perf: md format * add systemConfig schema (#2) * fix: markdown * fix: root * fix: root --------- Co-authored-by: heheer <[email protected]>
- Loading branch information
1 parent
b58249f
commit 84cf6b5
Showing
8 changed files
with
70 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export enum SystemConfigsTypeEnum { | ||
fastgpt = 'fastgpt', | ||
fastgptPro = 'fastgptPro' | ||
} | ||
|
||
export const SystemConfigsTypeMap = { | ||
[SystemConfigsTypeEnum.fastgpt]: { | ||
label: 'fastgpt' | ||
}, | ||
[SystemConfigsTypeEnum.fastgptPro]: { | ||
label: 'fastgptPro' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SystemConfigsTypeEnum } from "./constants"; | ||
|
||
export type SystemConfigsType = { | ||
_id: string; | ||
type: `${SystemConfigsTypeEnum}`; | ||
value: Record<string, any>; | ||
createTime: Date; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { SystemConfigsType } from '@fastgpt/global/common/system/config/type'; | ||
import { connectionMongo, type Model } from '../../../common/mongo'; | ||
import { SystemConfigsTypeMap } from '@fastgpt/global/common/system/config/constants'; | ||
|
||
const { Schema, model, models } = connectionMongo; | ||
|
||
const collectionName = 'systemConfigs'; | ||
const systemConfigSchema = new Schema({ | ||
type: { | ||
type: String, | ||
required: true, | ||
enum: Object.keys(SystemConfigsTypeMap) | ||
}, | ||
value: { | ||
type: Object, | ||
required: true | ||
}, | ||
createTime: { | ||
type: Date, | ||
default: () => new Date() | ||
} | ||
}) | ||
|
||
try { | ||
systemConfigSchema.index({ createTime: -1 }, { expireAfterSeconds: 90 * 24 * 60 * 60 }); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
export const MongoSystemConfigs: Model<SystemConfigsType>= | ||
models[collectionName] || model(collectionName, systemConfigSchema); | ||
MongoSystemConfigs.syncIndexes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters