refactor: getTeamsOfUser function
This commit is contained in:
@@ -264,28 +264,17 @@ export class TeamService implements UserDataHandler, OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getTeamsOfUser(uid: string, cursor: string | null): Promise<Team[]> {
|
async getTeamsOfUser(uid: string, cursor: string | null): Promise<Team[]> {
|
||||||
if (!cursor) {
|
|
||||||
const entries = await this.prisma.teamMember.findMany({
|
const entries = await this.prisma.teamMember.findMany({
|
||||||
take: 10,
|
take: 10,
|
||||||
where: {
|
skip: cursor ? 1 : 0,
|
||||||
userUid: uid,
|
cursor: cursor
|
||||||
},
|
? {
|
||||||
include: {
|
|
||||||
team: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return entries.map((entry) => entry.team);
|
|
||||||
} else {
|
|
||||||
const entries = await this.prisma.teamMember.findMany({
|
|
||||||
take: 10,
|
|
||||||
skip: 1,
|
|
||||||
cursor: {
|
|
||||||
teamID_userUid: {
|
teamID_userUid: {
|
||||||
teamID: cursor,
|
teamID: cursor,
|
||||||
userUid: uid,
|
userUid: uid,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
|
: undefined,
|
||||||
where: {
|
where: {
|
||||||
userUid: uid,
|
userUid: uid,
|
||||||
},
|
},
|
||||||
@@ -295,7 +284,6 @@ export class TeamService implements UserDataHandler, OnModuleInit {
|
|||||||
});
|
});
|
||||||
return entries.map((entry) => entry.team);
|
return entries.map((entry) => entry.team);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async getTeamWithID(teamID: string): Promise<Team | null> {
|
async getTeamWithID(teamID: string): Promise<Team | null> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user