mediumhype
mediumhype
DTDrizzle Team
Created by mediumhype on 9/12/2024 in #help
Is it possible to create a query without having a (postgres) db instance?
I can do this:
const query = sql`SELECT ... FROM...`;
const db = drizzle(..., {schema});
db.execute(query);
const query = sql`SELECT ... FROM...`;
const db = drizzle(..., {schema});
db.execute(query);
But is there anyway to do something like this:
const query = dummy.select(...).from(...);
const db = drizzle(..., {schema});
db.execute(query);
const query = dummy.select(...).from(...);
const db = drizzle(..., {schema});
db.execute(query);
It seems if I manually define the query like in the good old days I can pre-write a query ahead of time. But if I want to access the type-safe universe, it looks like I need to have a db instance set up BEFORE I use it to compose the query. I have a use case where I'd like to prewrite several queries for a query catalog. This catalog is built before the db object is instantiated.
2 replies