返回 AiToEarn
app-config.schema.ts
根目录 / project / aitoearn-backend / libs / mongodb / src / schemas / app-config.schema.ts
1 /*
2 * @Author: nevin
3 * @Date: 2022-11-16 22:04:18
4 * @LastEditTime: 2024-11-22 09:53:38
5 * @LastEditors: nevin
6 * @Description: 配置 AppConfigs appConfigs
7 */
8 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
9 import { DEFAULT_SCHEMA_OPTIONS } from '../mongodb.constants'
10 import { WithTimestampSchema } from './timestamp.schema'
11
12 @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'appConfigs' })
13 export class AppConfig extends WithTimestampSchema {
14 id: string
15
16 @Prop({ required: true, comment: '应用标识' })
17 appId: string
18
19 @Prop({ comment: '配置键名' })
20 key: string
21
22 @Prop({
23 comment: '配置值',
24 type: Object,
25 })
26 value: Record<string, any>
27
28 @Prop({
29 comment: '配置描述',
30 default: '',
31 })
32 description?: string
33
34 @Prop({
35 comment: '是否启用',
36 default: true,
37 })
38 enabled: boolean
39
40 @Prop({ type: Object })
41 metadata?: Record<string, any>
42 }
43
44 export const AppConfigSchema = SchemaFactory.createForClass(AppConfig)
45 AppConfigSchema.index({ appId: 1, key: 1 }, { unique: true })
46
46 lines TYPESCRIPT