Next.js Discord

Discord Forum

drizzle not showing columns

Answered
astro posted this in #help-forum
Open in Discord
im not able to query my columns in drizzle using .query method. this is my drizzle config:
import { type Config } from "drizzle-kit";

import { env } from "@/env";

export default {
  schema: "./src/server/db/schema",
  dialect: "postgresql",
  dbCredentials: {
    url: env.DATABASE_URL,
  },
  out: "./src/server/db/migrations",
} satisfies Config;
Answered by astro
i fixed it nvm
i was using a multi file schema(separate file for each table in db)
just needed to create an index.ts in root of my schema folder and export all schemas
export * from "./auth";
export * from "./campaigns";
export * from "./newsletters";
export * from "./smtpServers";
export * from "./subscribers";

and then pass it to my db object
import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import * as schema from "./schema";

const sql = neon(process.env.DATABASE_URL!);
export const db = drizzle(sql, { schema });
View full answer

1 Reply

i fixed it nvm
i was using a multi file schema(separate file for each table in db)
just needed to create an index.ts in root of my schema folder and export all schemas
export * from "./auth";
export * from "./campaigns";
export * from "./newsletters";
export * from "./smtpServers";
export * from "./subscribers";

and then pass it to my db object
import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import * as schema from "./schema";

const sql = neon(process.env.DATABASE_URL!);
export const db = drizzle(sql, { schema });
Answer