sanner
sanner
Explore posts from servers
HHono
Created by sanner on 9/2/2024 in #help
Knex + Hono + Bun Connection Errors
I was using knex on bun+hono and was attempting to make a connection via the following syntax
import { Knex, knex } from 'knex';
import pg from 'pg';

const client = knex({
client: 'pg', // Replace 'pg' with your database client if different
connection: {
host: "hostDB",
port: 5432,
user: "postgres",
password: "passwordDB",
database: "databaseName",
ssl: {
rejectUnauthorized: false,
},
},
searchPath: ['knex', 'public'], // Optional: Specify search path for PostgreSQL
});
import { Knex, knex } from 'knex';
import pg from 'pg';

const client = knex({
client: 'pg', // Replace 'pg' with your database client if different
connection: {
host: "hostDB",
port: 5432,
user: "postgres",
password: "passwordDB",
database: "databaseName",
ssl: {
rejectUnauthorized: false,
},
},
searchPath: ['knex', 'public'], // Optional: Specify search path for PostgreSQL
});
and i was getting the following error
TypeError: this.driver.Client is not a constructor
at Client_PG._acquireOnlyConnection (file:///home/sanner/Coding/node_modules/knex/lib/dialects/postgres/index.js:83:24)
at Client_PG.acquireRawConnection (file:///home/sanner/Coding//node_modules/knex/lib/dialects/postgres/index.js:101:17)
at create (file:///home/
/node_modules/knex/lib/client.js:262:39)
TypeError: this.driver.Client is not a constructor
at Client_PG._acquireOnlyConnection (file:///home/sanner/Coding/node_modules/knex/lib/dialects/postgres/index.js:83:24)
at Client_PG.acquireRawConnection (file:///home/sanner/Coding//node_modules/knex/lib/dialects/postgres/index.js:101:17)
at create (file:///home/
/node_modules/knex/lib/client.js:262:39)
I was trying to connect to Knex with a postgres client however I am getting this error, I tried many things such as creating a client and adding that to client. This code was able to work on a pnpm worker with nodejs, however it does not work with bun+hono
2 replies