Is your feature request related to a problem? Please describe.
Currently, leveraging the drizzle query API is not set up when generating scaffolds out of the box.
Describe the solution you'd like
Create a src/lib/db/schema/index.ts that exports a schema object, e.g.
import * as animals from "@/lib/db/schema/animals";
export const schema = {
animals,
};
In the src/lib/db/index.ts, pass the schema object into the drizzle client that gets instantiated, e.g.
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg"
import { env } from "@/lib/env.mjs";
import { schema } from "@/lib/db/schema";
export const pool = new Pool({
connectionString: env.DATABASE_URL,
});
export const db = drizzle(pool, {
schema
});
Whenever the generator creates a new model, the schema object gets automatically updated, e.g.
import * as animals from "@/lib/db/schema/animals";
import * as books from "@/lib/db/schema/books";
export const schema = {
animals,
books,
};
These changes will enable the drizzle query interface, which could simplify the default scaffolded queries that use drizzle.
Is your feature request related to a problem? Please describe. Currently, leveraging the drizzle query API is not set up when generating scaffolds out of the box.
Describe the solution you'd like Create a
src/lib/db/schema/index.ts
that exports a schema object, e.g.In the
src/lib/db/index.ts
, pass theschema
object into the drizzle client that gets instantiated, e.g.Whenever the generator creates a new model, the schema object gets automatically updated, e.g.
These changes will enable the drizzle query interface, which could simplify the default scaffolded queries that use drizzle.