mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00

* mongo init * perf: mongo connect * perf: tts perf: whisper and tts peref: tts whisper permission log reabase (#488) * perf: modal * i18n * perf: schema lean * feat: vision model format * perf: tts loading * perf: static data * perf: tts * feat: image * perf: image * perf: upload image and title * perf: image size * doc * perf: color * doc * speaking can not select file * doc
72 lines
1.5 KiB
TypeScript
72 lines
1.5 KiB
TypeScript
import { connectionMongo, type Model } from '../../common/mongo';
|
|
const { Schema, model, models } = connectionMongo;
|
|
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
|
|
import { PermissionTypeEnum, PermissionTypeMap } from '@fastgpt/global/support/permission/constant';
|
|
import {
|
|
TeamCollectionName,
|
|
TeamMemberCollectionName
|
|
} from '@fastgpt/global/support/user/team/constant';
|
|
|
|
export const appCollectionName = 'apps';
|
|
|
|
const AppSchema = new Schema({
|
|
userId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'user'
|
|
},
|
|
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: 'advanced',
|
|
enum: ['basic', 'advanced']
|
|
},
|
|
avatar: {
|
|
type: String,
|
|
default: '/icon/logo.svg'
|
|
},
|
|
intro: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
updateTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
modules: {
|
|
type: Array,
|
|
default: []
|
|
},
|
|
inited: {
|
|
type: Boolean
|
|
},
|
|
permission: {
|
|
type: String,
|
|
enum: Object.keys(PermissionTypeMap),
|
|
default: PermissionTypeEnum.private
|
|
}
|
|
});
|
|
|
|
try {
|
|
AppSchema.index({ updateTime: -1 });
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
export const MongoApp: Model<AppType> =
|
|
models[appCollectionName] || model(appCollectionName, AppSchema);
|
|
|
|
MongoApp.syncIndexes();
|