cumironin
DTDrizzle Team
•Created by cumironin on 10/19/2023 in #help
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 :
my drizzle config:
and i can't import with
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()
});
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()
});
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.
}
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.
}
@/db/schema
3 replies