diff --git a/packages/service/core/app/schema.ts b/packages/service/core/app/schema.ts index 3844a07f2..d6e6f0cb7 100644 --- a/packages/service/core/app/schema.ts +++ b/packages/service/core/app/schema.ts @@ -22,102 +22,107 @@ export const chatConfigType = { }; // schema -const AppSchema = new Schema({ - parentId: { - type: Schema.Types.ObjectId, - ref: AppCollectionName, - default: null - }, - teamId: { - type: Schema.Types.ObjectId, - ref: TeamCollectionName, - required: true - }, - tmbId: { - type: Schema.Types.ObjectId, - ref: TeamMemberCollectionName, - required: true - }, - name: { - type: String, - required: true - }, - type: { - type: String, - default: AppTypeEnum.workflow, - enum: Object.values(AppTypeEnum) - }, - version: { - type: String, - enum: ['v1', 'v2'] - }, - avatar: { - type: String, - default: '/icon/logo.svg' - }, - intro: { - type: String, - default: '' - }, - - updateTime: { - type: Date, - default: () => new Date() - }, - - // role and auth - teamTags: { - type: [String] - }, - - // save app(Not publish) - modules: { - type: Array, - default: [] - }, - edges: { - type: Array, - default: [] - }, - chatConfig: { - type: chatConfigType - }, - // plugin config - pluginData: { +const AppSchema = new Schema( + { + parentId: { + type: Schema.Types.ObjectId, + ref: AppCollectionName, + default: null + }, + teamId: { + type: Schema.Types.ObjectId, + ref: TeamCollectionName, + required: true + }, + tmbId: { + type: Schema.Types.ObjectId, + ref: TeamMemberCollectionName, + required: true + }, + name: { + type: String, + required: true + }, type: { - nodeVersion: String, - pluginUniId: String, - apiSchemaStr: String, // http plugin - customHeaders: String // http plugin - } - }, - - scheduledTriggerConfig: { - cronString: { - type: String + type: String, + default: AppTypeEnum.workflow, + enum: Object.values(AppTypeEnum) }, - timezone: { - type: String + version: { + type: String, + enum: ['v1', 'v2'] + }, + avatar: { + type: String, + default: '/icon/logo.svg' + }, + intro: { + type: String, + default: '' }, - defaultPrompt: { - type: String - } - }, - scheduledTriggerNextTime: { - type: Date - }, - inited: { - type: Boolean - }, - inheritPermission: { - type: Boolean, - default: true - }, + updateTime: { + type: Date, + default: () => new Date() + }, - // abandoned - defaultPermission: Number -}); + // role and auth + teamTags: { + type: [String] + }, + + // save app(Not publish) + modules: { + type: Array, + default: [] + }, + edges: { + type: Array, + default: [] + }, + chatConfig: { + type: chatConfigType + }, + // plugin config + pluginData: { + type: { + nodeVersion: String, + pluginUniId: String, + apiSchemaStr: String, // http plugin + customHeaders: String // http plugin + } + }, + + scheduledTriggerConfig: { + cronString: { + type: String + }, + timezone: { + type: String + }, + defaultPrompt: { + type: String + } + }, + scheduledTriggerNextTime: { + type: Date + }, + + inited: { + type: Boolean + }, + inheritPermission: { + type: Boolean, + default: true + }, + + // abandoned + defaultPermission: Number + }, + { + minimize: false + } +); AppSchema.index({ type: 1 }); AppSchema.index({ teamId: 1, updateTime: -1 }); diff --git a/packages/service/core/app/version/schema.ts b/packages/service/core/app/version/schema.ts index ea1e5bd61..1a1361f08 100644 --- a/packages/service/core/app/version/schema.ts +++ b/packages/service/core/app/version/schema.ts @@ -6,35 +6,40 @@ import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/cons export const AppVersionCollectionName = 'app_versions'; -const AppVersionSchema = new Schema({ - tmbId: { - type: String, - ref: TeamMemberCollectionName, - required: true +const AppVersionSchema = new Schema( + { + tmbId: { + type: String, + ref: TeamMemberCollectionName, + required: true + }, + appId: { + type: Schema.Types.ObjectId, + ref: AppVersionCollectionName, + required: true + }, + time: { + type: Date, + default: () => new Date() + }, + nodes: { + type: Array, + default: [] + }, + edges: { + type: Array, + default: [] + }, + chatConfig: { + type: chatConfigType + }, + isPublish: Boolean, + versionName: String }, - appId: { - type: Schema.Types.ObjectId, - ref: AppVersionCollectionName, - required: true - }, - time: { - type: Date, - default: () => new Date() - }, - nodes: { - type: Array, - default: [] - }, - edges: { - type: Array, - default: [] - }, - chatConfig: { - type: chatConfigType - }, - isPublish: Boolean, - versionName: String -}); + { + minimize: false + } +); try { AppVersionSchema.index({ appId: 1, time: -1 });