21 lines
594 B
TypeScript
21 lines
594 B
TypeScript
import { logger } from "@/lib/logger";
|
|
import PocketBase from "pocketbase";
|
|
import { transformTeam } from "@/lib/pocketbase/util/transform-types";
|
|
import { Team } from "@/features/teams/types";
|
|
|
|
export function createTeamsService(pb: PocketBase) {
|
|
return {
|
|
async getTeam(id: string): Promise<Team | null> {
|
|
try {
|
|
logger.info('PocketBase | Getting team', id);
|
|
const result = await pb.collection('teams').getOne(id, {
|
|
expand: 'players, tournaments'
|
|
});
|
|
return transformTeam(result);
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
};
|
|
}
|