Unable to use db.query but able to use reqular db.select

I had the problem with using Drizzle Queries, it isn't working but works with regular select
my schema :
export const menuTable = pgTable('menu', {
    id: varchar('id', { length: 255 }).primaryKey(),
    name: varchar('name', { length: 100 }),
    urlRestrict: varchar('url_restrict', { length: 100 }),
    svg: varchar('svg', { length: 512 })
});

export const menuTableRelations = relations(menuTable, ({ many }) => ({
    menuRole: many(roleToMenuTable),
    SubMenu: many(subMenuTable)
}));

export const subMenuTable = pgTable('sub_menu', {
    id: varchar('id', { length: 255 }).primaryKey(),
    name: varchar('name', { length: 100 }),
    urlRestrict: varchar('url_restrict', { length: 100 }),
    menuId: varchar('menu_id')
        .notNull()
        .references(() => menuTable.id, { onDelete: 'cascade' })
        .notNull()
});


my drizzle config:
import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
import * as dotenv from 'dotenv';
dotenv.config();

const client = new Client({
    connectionString: process.env.DATABASE_URL
});

await client.connect();
const db = drizzle(client);

export async function GET() {
    const result = await db.query.
}

and i can't import with @/db/schema
Was this page helpful?