ilajosmanov
ilajosmanov
DTDrizzle Team
Created by ilajosmanov on 3/3/2024 in #help
Using extras in where
Hey, folks! Could you tell me, is it possible to get keys from "extras" in "where" for filtering?
let users = await db.query.UsersTable.findMany({
extras: {
targetName: sql<string>`lower(${UsersTable.firstName})`.as("target_name")
},
where: () =>
and(
inArray(
UsersTable.id,
employeesRoles.map((r) => r.userId)
),
// here i need to use target_name for querying
),
with: {
roles: true
}

});
let users = await db.query.UsersTable.findMany({
extras: {
targetName: sql<string>`lower(${UsersTable.firstName})`.as("target_name")
},
where: () =>
and(
inArray(
UsersTable.id,
employeesRoles.map((r) => r.userId)
),
// here i need to use target_name for querying
),
with: {
roles: true
}

});
1 replies