refactor: org pathId (#3516)
This commit is contained in:
@@ -2,8 +2,8 @@ import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant';
|
||||
import { OrgCollectionName } from '@fastgpt/global/support/user/team/org/constant';
|
||||
import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
|
||||
import { connectionMongo, getMongoModel } from '../../../common/mongo';
|
||||
import { ResourcePermissionCollectionName } from '../schema';
|
||||
import { OrgMemberCollectionName } from './orgMemberSchema';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
const { Schema } = connectionMongo;
|
||||
|
||||
function requiredStringPath(this: OrgSchemaType) {
|
||||
@@ -17,6 +17,12 @@ export const OrgSchema = new Schema(
|
||||
ref: TeamCollectionName,
|
||||
required: true
|
||||
},
|
||||
pathId: {
|
||||
// path id, only used for path
|
||||
type: String,
|
||||
required: true,
|
||||
default: () => getNanoid()
|
||||
},
|
||||
path: {
|
||||
type: String,
|
||||
required: requiredStringPath // allow empty string, but not null
|
||||
@@ -57,6 +63,15 @@ try {
|
||||
teamId: 1,
|
||||
path: 1
|
||||
});
|
||||
OrgSchema.index(
|
||||
{
|
||||
teamId: 1,
|
||||
pathId: 1
|
||||
},
|
||||
{
|
||||
unique: true
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user