Closed TusharWatts closed 3 months ago
Hey 👋
You're not supposed to use mysql2/promises
, but mysql2
.
@igalklebanov , its the same issue with mysql2
I'm using "mysql2": "^3.10.1"
database.ts file:-
import { Database } from './types'; // this is the Database interface we defined earlier
import { createPool } from 'mysql2'; // do not use 'mysql2/promises'!
import { Kysely, MysqlDialect } from 'kysely';
const dialect = new MysqlDialect({
pool: createPool({
database: 'my_db',
host: '127.0.0.1',
user: 'username',
password: 'password',
port: 3308,
connectionLimit: 10
})
});
export const db = new Kysely<Database>({
dialect
});
How are you "checking, db.schema"?
Got it, the issue has been resolved. It was stupid issue from my end. I was importing the db from the database file as default import, hence it was not working. My bad!
Thanks anyway
On initialization, db.schema returns undefined Here is my code:
Database.ts
On checking, db.schema gives me undefined I'm using mysql as the dialect And using the following versions for mysql and kysely: "kysely": "^0.27.3", "mysql": "^2.18.1"