ReviewOS

stacks/bun-query-builder

How to Specify Database Settings

#1001
Closed djamez opened this 22 days ago · 0 comments
22 days ago

Hello

I stumbled upon this project and having used Eloquent, Knex, Kysely and Objection; and also bun's SQL;, I do think - from the documentation - that this presents a really nice DX that draws from the afore-mentioned libraries.

My attempt to test it has been unsuccessful. I cannot seem to be able to specify database settings.

I tried this:

config.dialect = 'mysql';
config.sql.randomFunction = 'RAND()';
config.sql.sharedLockSyntax = 'LOCK IN SHARE MODE';
config.sql.jsonContainsMode = 'function';

config.database.url = "mysql://root:password@localhost:3306/testdb";

...
const db = createQueryBuilder(...);

const ok = await db.ping()
await db.waitForReady({ attempts: 100, delayMs: 250 })

..yields "Database not ready after waiting".

Attempting to use the longer version:

config.database.host = 'localhost';
config.database.port = 3306;
config.database.username = 'root';
config.database.password = 'password';
config.database.database = 'testdb';

...yields the same error. The documentation does not mention this anywhere - or at least I could not find it. Not even in the examples.

Please advise.

PS: The documentation on the website (https://bun-query-builder.netlify.app) is lagging behind the repo quite significantly.

Sign in to comment on this issue.