Closed johurul-haque closed 2 weeks ago
Just curious, why would you want a full namespace import? Personally, I prefer being able to import exactly what I need, where I need it.
If you're just trying to avoid a long list of imports when defining your database schema, you can use the new table callback feature introduced in drizzle-orm@0.34.0
.
Instead of this:
import { boolean, pgTable, text, uuid } from "drizzle-orm/pg-core";
export const ingredients = pgTable("ingredients", {
id: uuid("id").defaultRandom().primaryKey(),
name: text("name").notNull(),
description: text("description"),
inStock: boolean("in_stock").default(true),
});
You can now do this:
import { pgTable } from "drizzle-orm/pg-core";
export const ingredients = pgTable("ingredients", (t) => ({
id: t.uuid().defaultRandom().primaryKey(),
name: t.text().notNull(),
description: t.text(),
inStock: t.boolean("in_stock").default(true),
}));
This also ensures you're using the correct column types for that specific dialect.
Source: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.34.0
Describe what you want
Current behavior:
Requested behavior:
At the moment, I can do
* as d
to mimic this, but I won't get intellisense on my editor for that. I have to manually write the import statement every time.