`TypeError: Cannot read properties of undefined (reading 'query')`

import "dotenv/config";
import * as schema from "./schema.js";
import { drizzle } from "drizzle-orm/node-postgres";

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

export { db };
import "dotenv/config";
import * as schema from "./schema.js";
import { drizzle } from "drizzle-orm/node-postgres";

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

export { db };
```
10 Replies
acronie
acronieOP2mo ago
Getting this weird error
await db.insert(product).values({
description: body.description,
images: body.images,
name: body.name,
price: body.price,
thumbnail: body.thumbnail,
});
await db.insert(product).values({
description: body.description,
images: body.images,
name: body.name,
price: body.price,
thumbnail: body.thumbnail,
});
美味的小圓
Yeah I'm also facing this @acronie What runtime you are using? :animethink:
Imam
Imam2w ago
is it fixed? @美味的小圓 @acronie sorry for tagging you
acronie
acronieOP2w ago
the issue was with runtime iirc
Imam
Imam2w ago
im using hono with node js, what are you using? @acronie
acronie
acronieOP2w ago
same, I meant driver for pg or whatever your db is
Imam
Imam2w ago
i know it is working fine when im using express instead of hono yes im using pg how you fix it? here is my drizzle client code:
import 'dotenv/config';

import { drizzle } from 'drizzle-orm/node-postgres';
import * as schema from './schema';

export const db = drizzle(process.env.DATABASE_URL!, {
casing: 'snake_case',
schema,
});

export * from 'drizzle-orm';
import 'dotenv/config';

import { drizzle } from 'drizzle-orm/node-postgres';
import * as schema from './schema';

export const db = drizzle(process.env.DATABASE_URL!, {
casing: 'snake_case',
schema,
});

export * from 'drizzle-orm';
i was using mysql with express it is just working fine, now im trying hono with postgres got this error
美味的小圓
I remembered that I just checked connection maybe? :animethink: Seems that this happened if it can’t connect to database
Imam
Imam2w ago
now it is working, im changing using postgres-js over node-postgres, but what the differences between these, i don't really understand🤔
import 'dotenv/config';

import { drizzle } from 'drizzle-orm/postgres-js';
import * as schema from './schema';

export const db = drizzle(process.env.DATABASE_URL!, {
casing: 'snake_case',
schema,
});

export * from 'drizzle-orm';
import 'dotenv/config';

import { drizzle } from 'drizzle-orm/postgres-js';
import * as schema from './schema';

export const db = drizzle(process.env.DATABASE_URL!, {
casing: 'snake_case',
schema,
});

export * from 'drizzle-orm';
美味的小圓
I don't understand either I use Hono & Deno No problemo after I checked database connection and env file reading again :ThinkIn: This is my code:
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from "../Schema/DatabaseSchema.ts";

const dbClient = drizzle(Deno.env.get("DBURL"), { schema: { ...schema } });

export default dbClient;
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from "../Schema/DatabaseSchema.ts";

const dbClient = drizzle(Deno.env.get("DBURL"), { schema: { ...schema } });

export default dbClient;
And use deno run -A --env-file=.env main.ts to make deno read .env file when start up
Want results from more Discord servers?
Add your server