DT
Drizzle Team10mo ago
JT

query to text

Is there a way to get a query output as text for debugging/logging purposes?
4 Replies
povey
povey10mo 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
povey10mo ago
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Mykhailo
Mykhailo10mo 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
JTOP10mo ago
Thank you!
Want results from more Discord servers?
Add your server