TJ
TJ
Explore posts from servers
DTDrizzle Team
Created by TJ on 8/13/2024 in #help
MariaDB support?
I see that Support MariaDB is moved to done with the description of it been released to latest on NPM. Does this means MariaDB is officially supported in the latest release? https://github.com/drizzle-team/drizzle-orm/issues/203
1 replies
DTDrizzle Team
Created by TJ on 7/17/2024 in #help
Error handling
Hi, Currently this how I handle the database error thrown from Drizzle,
try {
...
} catch (error) {
if (error.sqlMessage) {
// toast a message "There was database error, contact administrator"
} else {
...
}
}
try {
...
} catch (error) {
if (error.sqlMessage) {
// toast a message "There was database error, contact administrator"
} else {
...
}
}
Is this the correct way to check if it is a database error?
3 replies
DTDrizzle Team
Created by TJ on 6/16/2024 in #help
Conflicting peer dependency of [email protected] when installing [email protected] in Next.js 14.2.4
Hi I'm install drizzle-orm in a Next.js project initialized with [email protected]. This new project has dependency to React 18.3.1. Unfortunately, we encounter the following dependency error when install latest drizzle-orm
$ npm install drizzle-orm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! peer react@"^18.3.1" from [email protected]
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! react-dom@"^18" from the root project
npm ERR! 2 more (styled-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from [email protected]
npm ERR! node_modules/react-native
npm ERR! peer react-native@">0.73.0" from @op-engineering/[email protected]
npm ERR! node_modules/@op-engineering/op-sqlite
npm ERR! peerOptional @op-engineering/op-sqlite@">=2" from [email protected]
npm ERR! node_modules/drizzle-orm
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
$ npm install drizzle-orm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! peer react@"^18.3.1" from [email protected]
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! react-dom@"^18" from the root project
npm ERR! 2 more (styled-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from [email protected]
npm ERR! node_modules/react-native
npm ERR! peer react-native@">0.73.0" from @op-engineering/[email protected]
npm ERR! node_modules/@op-engineering/op-sqlite
npm ERR! peerOptional @op-engineering/op-sqlite@">=2" from [email protected]
npm ERR! node_modules/drizzle-orm
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Do you have any idea of what could be the problem? Shall we use --force to workaround this error?
6 replies
DTDrizzle Team
Created by TJ on 5/8/2024 in #help
How to share Drizzle schema in multiple projects?
Hi, I have an Express.js application running with Drizzle ORM. The schemas are defined and migration are generated in this repository, no problem. and now I'm going to have another application written in Next.js and it is going to access the same database. How can I share the Drizzle schema in multiple projects? Currently, I'm duplicating the Drizzle's schema from the previous Express.js application repository and make sure I don't run the migration. Do you have a better suggestion?
3 replies
DTDrizzle Team
Created by TJ on 5/7/2024 in #help
How to share the transaction in multiple services?
Hi, This is more like a design question. I'm using Drizzle ORM in Express.js application. I have userService and auditService to update the database records. Before the database transaction, I basically call the services like this,
router.post('/', async (req, res) => {
userService.create('john')
auditService.log('Create user john')
})
router.post('/', async (req, res) => {
userService.create('john')
auditService.log('Create user john')
})
and then with the database transaction,
router.post('/', async (req, res) => {
await db.transaction(async (tx) => {
userService.create(tx, 'john')
auditService.log(tx, 'Create user john')
})
})
router.post('/', async (req, res) => {
await db.transaction(async (tx) => {
userService.create(tx, 'john')
auditService.log(tx, 'Create user john')
})
})
Note that in the above, I have to pass the tx transaction to every service function. Is there a more elegant way than passing the tx to every function?
3 replies
DTDrizzle Team
Created by TJ on 4/24/2024 in #help
Access MariaDB in Drizzle using node-mysql2?
Hi, Drizzle ORM does not support MariaDB officially (see https://github.com/drizzle-team/drizzle-orm/pull/1692). However, I have seen discussions of using Drizzle to access MariaDB (using node-mysql2 driver). Is this recommended? Is there any compatibility issue?
4 replies