diff --git a/frontend/src/app/db/db.ts b/frontend/src/app/db/db.ts index 3c02312..08204e9 100644 --- a/frontend/src/app/db/db.ts +++ b/frontend/src/app/db/db.ts @@ -5,7 +5,5 @@ if (!process.env.DATABASE_URL) { throw new Error("DATABASE_URL is not defined in environment variables"); } - -const queryClient = postgres(process.env.DATABASE_URL); -const db = drizzle({ client: queryClient }); -const result = await db.execute('select 1'); \ No newline at end of file +const sqlClient = postgres(process.env.DATABASE_URL); +export const db = drizzle(sqlClient); \ No newline at end of file diff --git a/frontend/src/app/db/schema/buildings.ts b/frontend/src/app/db/schema/buildings.ts new file mode 100644 index 0000000..d0aedb2 --- /dev/null +++ b/frontend/src/app/db/schema/buildings.ts @@ -0,0 +1,10 @@ +import { pgTable, text, uuid } from 'drizzle-orm/pg-core'; + +export const buildings = pgTable('buildings', { + id: uuid('id').defaultRandom().primaryKey(), + address: text('address').notNull(), + postcode: text('postcode').notNull(), + UPRN: text('UPRN').notNull(), + landlordId: text('landlord_id').notNull(), + domnaId: text('domna_id').notNull(), +}); \ No newline at end of file diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index d6785dd..6336f8a 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -1,6 +1,55 @@ +// app/page.tsx +import { db } from './db/db'; // adjust path if needed +import { buildings } from './db/schema/buildings'; + +type Building = { + id: string; + address: string; + postcode: string; + uprn: string; + landlordId: string; + domnaId: string; +}; + +export default async function Home() { + const buildingRows = await db.select().from(buildings); + + const buildingsData: Building[] = buildingRows.map((b) => ({ + id: b.id.toString(), + address: b.address, + postcode: b.postcode, + uprn: b.UPRN, + landlordId: b.landlordId, + domnaId: b.domnaId, + })); -export default function Home() { return ( -
| ID | +Address | +Postcode | +UPRN | +Landlord ID | +Domna ID | +
|---|---|---|---|---|---|
| {b.id} | +{b.address} | +{b.postcode} | +{b.uprn} | +{b.landlordId} | +{b.domnaId} | +