| 2 | import { findAccountByPath } from 'services/accounts'; |
| 3 | |
| 4 | class CommunityService { |
| 5 | static async find(params: any): Promise<accounts | null> { |
| 6 | if ( |
| 7 | params && |
| 8 | params.communityId && |
| 9 | typeof params.communityId === 'string' |
| 10 | ) { |
| 11 | return prisma.accounts.findFirst({ |
| 12 | where: { id: params.communityId }, |
| 13 | }); |
| 14 | } |
| 15 | if ( |
| 16 | params && |
| 17 | params.communityName && |
| 18 | typeof params.communityName === 'string' |
| 19 | ) { |
| 20 | return findAccountByPath(params.communityName); |
| 21 | } |
| 22 | return null; |
| 23 | } |
| 24 | |
| 25 | static async findByAuthId(authId: string): Promise<accounts[]> { |
| 26 | return prisma.auths |
| 27 | .findMany({ |
| 28 | where: { |
| 29 | id: authId, |
| 30 | }, |
| 31 | select: { users: { select: { account: true } } }, |
| 32 | }) |
| 33 | .then((rows) => |
| 34 | rows.map((row) => row.users.map((user) => user.account)).flat() |
| 35 | ); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | export default CommunityService; |
nothing calls this directly
no outgoing calls
no test coverage detected