DT
Drizzle Team•12mo ago
asciant

Drizzle within class (cannot read properties of undefined)

Hi everyone 👋 I'm in the process of moving my app over from Prisma to Drizzle and I encountered a minor issue that I'm hoping you can assist with. I created wrappers as models to use in my app and would interact with the DB through this abstration layer. However, my setup with Prisma does not seem to work with Drizzle, can anyone help to see where I'm going wrong. I created a gist with some examples of both the Prisma model and the Drizzle model (https://gist.github.com/asciant/ea34c67fb56656f367183ce1f1069606), however when I try and use the model I recieve this error:
⨯ node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js (111:31) @ buildRelationalQuery
⨯ Internal error: TypeError: Cannot read properties of undefined (reading 'buildRelationalQuery')
at QueryPromise._toSQL (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:82:36)
at QueryPromise.prepare (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:72:44)
at QueryPromise.executeRaw (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:102:25)
at QueryPromise.execute (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:107:21)
at QueryPromise.then (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/query-promise.js:28:21)
null
⨯ node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js (111:31) @ buildRelationalQuery
⨯ Internal error: TypeError: Cannot read properties of undefined (reading 'buildRelationalQuery')
at QueryPromise._toSQL (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:82:36)
at QueryPromise.prepare (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:72:44)
at QueryPromise.executeRaw (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:102:25)
at QueryPromise.execute (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/query-builders/query.js:107:21)
at QueryPromise.then (./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/query-promise.js:28:21)
null
1 Reply
asciant
asciantOP•12mo ago
I call the method with this way:
const user = await UserModel.findFirst({
where: (users, { eq }) => eq(users.id, 1),
});
const user = await UserModel.findFirst({
where: (users, { eq }) => eq(users.id, 1),
});
Want results from more Discord servers?
Add your server