metowo
metowo
DTDrizzle Team
Created by metowo on 7/14/2024 in #help
db.query returns empty object
I'm using commonjs for swapping out the query builder from knex and bookshelf with drizzle and am seeing that logging db.query returns an empty object which I found because db.query.users.findFirst was giving me a can't call findfirst on undefined error. this is my schema
const users = mySchema.table('users', {
id: int('id').primaryKey().autoincrement(),
username: varchar('username', { length: 100 }),
password: varchar('password', { length: 100 }),
});
const users = mySchema.table('users', {
id: int('id').primaryKey().autoincrement(),
username: varchar('username', { length: 100 }),
password: varchar('password', { length: 100 }),
});
and my db config
const connection = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
charset: 'utf8',
});

module.exports = connection
.then(
(conn) =>
drizzle(conn, {
schema,
mode: 'default',
})
).then((db) => console.log(db) || db); // logging here shows me that db.query is {}
const connection = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
charset: 'utf8',
});

module.exports = connection
.then(
(conn) =>
drizzle(conn, {
schema,
mode: 'default',
})
).then((db) => console.log(db) || db); // logging here shows me that db.query is {}
12 replies