Conditionally return OR execute drizzle query

How can I achieve something like this (see sample code below)? my use case is that I have a base repository with CRUD methods that abstract over drizzle, but sometimes, I only need to return the query in cases where I need to extend it (e.g., override where condition, etc.).
async function someMethod(record: any, queryOnly: boolean) {
const query = db.insert(entity).values(record);
if (queryOnly) {
return query.$dynamic();
}

const result = await query
return result
}
async function someMethod(record: any, queryOnly: boolean) {
const query = db.insert(entity).values(record);
if (queryOnly) {
return query.$dynamic();
}

const result = await query
return result
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server