import { db } from "$lib/server/db"; import * as table from "$lib/server/db/schema"; import type { PageServerLoad } from "./$types"; export const load: PageServerLoad = async ({ params }) => { { const floor = await db.select({ floor: table.plans.floor, json: table.plans.plan }).from(table.plans); if (floor.length == 0) { await db.insert(table.plans).values({ floor: params.slug, plan: { "regions": [ { "start": { "x": 100, "y": 100 }, "end": { "x": 400, "y": 100 } }, { "start": { "x": 400, "y": 100 }, "end": { "x": 400, "y": 300 } }, { "start": { "x": 400, "y": 300 }, "end": { "x": 100, "y": 300 } }, { "start": { "x": 100, "y": 300 }, "end": { "x": 100, "y": 100 } } ], "doors": [ { "location": { "x": 240, "y": 100 }, "width": 50, "rotation": 0 } ], "furnitures": [ { "minBound": { "x": 150, "y": 150 }, "maxBound": { "x": 200, "y": 200 }, "equipName": "Table", "xPlacement": 150, "yPlacement": 150, "rotation": 0 } ] } }); } } const floor = await db.select({ floor: table.plans.floor, json: table.plans.plan }).from(table.plans); return { slug: params.slug, floor: floor }; };