non-SQL code in RQB extras

here is the custom fields doc for relational query builder: https://orm.drizzle.team/docs/rqb#include-custom-fields i would like to have an "extra" field in my query that is generated via plain typescript, not sql. so, something like:
const threads = await db.query.dmThread.findMany({
where: or(eq(dmThread.userA, locals.user.id), eq(dmThread.userB, locals.user.id)),
extras: {
other: locals.user.id == dmThread.userA ? dmThread.userA : dmThread.userB
}
});
const threads = await db.query.dmThread.findMany({
where: or(eq(dmThread.userA, locals.user.id), eq(dmThread.userB, locals.user.id)),
extras: {
other: locals.user.id == dmThread.userA ? dmThread.userA : dmThread.userB
}
});
how can i do this while still preserving typing, concise code etc. that drizzle usually provides? do i really need to iterate over all this and do Object.assign (if so, how would i still ensure the data is typed?) or is there a better way?
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?