mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 12:20:34 +00:00

* feat: log store * fix: full text search match query * perf: mongo schema import, Avoid duplicate import
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { connectionMongo, getMongoModel, type Model } from '../../../common/mongo';
|
|
const { Schema, model, models } = connectionMongo;
|
|
import { TeamMemberSchema as TeamMemberType } from '@fastgpt/global/support/user/team/type.d';
|
|
import { userCollectionName } from '../../user/schema';
|
|
import {
|
|
TeamMemberRoleMap,
|
|
TeamMemberStatusMap,
|
|
TeamMemberCollectionName,
|
|
TeamCollectionName
|
|
} from '@fastgpt/global/support/user/team/constant';
|
|
|
|
const TeamMemberSchema = new Schema({
|
|
teamId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamCollectionName,
|
|
required: true
|
|
},
|
|
userId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: userCollectionName,
|
|
required: true
|
|
},
|
|
name: {
|
|
type: String,
|
|
default: 'Member'
|
|
},
|
|
role: {
|
|
type: String,
|
|
enum: Object.keys(TeamMemberRoleMap)
|
|
},
|
|
status: {
|
|
type: String,
|
|
enum: Object.keys(TeamMemberStatusMap)
|
|
},
|
|
createTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
defaultTeam: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
});
|
|
|
|
try {
|
|
TeamMemberSchema.index({ teamId: 1 }, { background: true });
|
|
TeamMemberSchema.index({ userId: 1 }, { background: true });
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
export const MongoTeamMember = getMongoModel<TeamMemberType>(
|
|
TeamMemberCollectionName,
|
|
TeamMemberSchema
|
|
);
|