DT
Drizzle Team11mo ago
JT

query to text

Is there a way to get a query output as text for debugging/logging purposes?
4 Replies
povey
povey11mo ago
There's a logging parameter when initializing the drizzle client that should do what you want, print out the SQL in the console.
povey
povey11mo ago
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Mykhailo
Mykhailo11mo ago
@JT or you can use .toSQL() method:
const query = db.select().from(user).toSQL();

console.log(query);
const query = db.select().from(user).toSQL();

console.log(query);
{
sql: 'select "id", "email", "emailVerified", "username", "name", "image", "createdAt" from "user"',
params: []
}
{
sql: 'select "id", "email", "emailVerified", "username", "name", "image", "createdAt" from "user"',
params: []
}
JT
JTOP11mo ago
Thank you!
Want results from more Discord servers?
Add your server