29 lines
604 B
TypeScript
29 lines
604 B
TypeScript
import { db } from '$lib/server/db';
|
|
import * as schema from '$lib/server/db/schema';
|
|
import type { Actions } from './$types';
|
|
|
|
export const load = async () => {
|
|
return await getTeams();
|
|
};
|
|
|
|
export const actions = {
|
|
addEntry: async (event) => {
|
|
console.log('something');
|
|
}
|
|
} satisfies Actions;
|
|
|
|
let testScore = 0;
|
|
|
|
export async function getTeams() {
|
|
const allTeams = await db.select().from(schema.teamScoresView);
|
|
console.log(allTeams);
|
|
return {
|
|
teams: allTeams.map((team) => ({
|
|
...team,
|
|
name: team.teamName,
|
|
color: team.teamColor,
|
|
points: team.totalPoints || testScore
|
|
}))
|
|
};
|
|
}
|