path 为空字符情况处理

This commit is contained in:
Wang Kejun 2023-09-24 10:12:27 +08:00
parent 6fa363f011
commit a1336b93a4
1 changed files with 29 additions and 0 deletions

View File

@ -1491,6 +1491,35 @@ export async function getUserRelationsByActions<ED extends EntityDict & BaseEnti
const getUserRelations = async (urAuths: Partial<ED['actionAuth']['Schema']>[]) => { const getUserRelations = async (urAuths: Partial<ED['actionAuth']['Schema']>[]) => {
const makeRelationIterator = (path: string, relationIds: string[]) => { const makeRelationIterator = (path: string, relationIds: string[]) => {
if (path === '') {
return {
projection: {
id: 1,
userRelation$entity: {
$entity: 'userRelation',
data: {
id: 1,
relationId: 1,
relation: {
id: 1,
name: 1,
},
entity: 1,
entityId: 1,
userId: 1,
},
filter: {
relationId: {
$in: relationIds,
},
},
} as ED['userRelation']['Selection'],
} as ED[keyof ED]['Selection']['data'],
getData: (d: Partial<ED[keyof ED]['Schema']>) => {
return d.userRelation$entity;
},
};
}
const paths = path.split('.'); const paths = path.split('.');
const makeIter = (e: keyof ED, idx: number): { const makeIter = (e: keyof ED, idx: number): {