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
and my db config
8 Replies
How schema is imported? Looks like it is missing when creating drizzle
this is the more complete setup:
schema.js
when logging mySchema
, I get
and config.js
which does show undefined
for db.schema
Ok! This is not the const schema that you have to set to the schema property of drizzle (if schema you import is mySchema in your example)😬
The schema property should be all your exported schema, tables and relations.
For esm it is import * as schema, so for commonjs maybe const schema = require(…)?
this is what I get when I log
db
I also tried to eliminate the potential issue of it being import related by having everything in the same file and I'm still seeing the same thing
is how I updated itGitHub
drizzle-mysql-commonjs/config.js at main · rphlmr/drizzle-mysql-com...
Contribute to rphlmr/drizzle-mysql-commonjs development by creating an account on GitHub.
You must use the sync
mysql2
instead of the promise version
There is a bug with custom schema and drizzle kit for MySQL :/ https://github.com/drizzle-team/drizzle-orm/issues/2134
GitHub
[BUG]: Incorrect migration generation for indexes and constraints w...
What version of drizzle-orm are you using? 0.30.7 What version of drizzle-kit are you using? 0.20.14 Describe the Bug Drizzle kit generates incorrect migrations for tables with indexes and foreign ...
thanks