Currently I've lost types for my queries. This is not the first time this has happened, but previously the culprit was that I had upgraded the drizzle-orm version in one package without updating the other(s). Each of the packages and apps are using drizzle-orm
0.44.2
0.44.2
, confirmed in my pnpm-lockfile that there are no other listed versions.
In the main web app I create a drizzle client:
import { drizzle } from 'drizzle-orm/node-postgres';import { DB_URL } from '$env/static/private';import Pg from 'pg';import { exportedSchema } from '@sungmanito/db';const client = new Pg.Pool({ connectionString: DB_URL,});await client.connect();export const db = drizzle(client, { logger: true, schema: exportedSchema,});
import { drizzle } from 'drizzle-orm/node-postgres';import { DB_URL } from '$env/static/private';import Pg from 'pg';import { exportedSchema } from '@sungmanito/db';const client = new Pg.Pool({ connectionString: DB_URL,});await client.connect();export const db = drizzle(client, { logger: true, schema: exportedSchema,});
and in the loader functions (sveltekit) I tend to do stuff like
import { db } from '$lib/server/db';import { exportedSchema } from '@sungmanito/db';export const load = async () => { const results = await db.select().from(exportedSchema.bills); return { results };}
import { db } from '$lib/server/db';import { exportedSchema } from '@sungmanito/db';export const load = async () => { const results = await db.select().from(exportedSchema.bills); return { results };}
More confusing, is if i take any of the table definitions and just include them in the repo, it works fine.
The types that come back for a typical query, like where I'm loading all the bills, their most recent payment status, and the name of the household associated with that bill, is this