MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / CommunityService

Class CommunityService

apps/web/services/community/index.tsx:4–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import { findAccountByPath } from 'services/accounts';
3
4class 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
39export default CommunityService;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected