Possible to reuse columns while selecting?

Apologies if this is documented somewhere and I've missed it

I am currently in the process of transitioning from Prisma and follow this pattern quite often:

// This resides in a separate file for utilization across various queries
export const usersSelect = Prisma.validator<Prisma.usersSelect>()({
   id: true,
   name: true,
   ...
   someRelation: {
      select: {
         someData: true,
      },
   },
});

// We construct our 'where' condition based on certain options...
let usersWhere: Prisma.usersWhereInput = {
  banned: false
};
if (includeInactiveUsers) {
  usersWhere = {
    ...usersWhere,
    inactive: true
}
// Execute the query
const users = await prisma.users.findMany({
  select: usersSelect
  where: usersWhere
  ...
});


I am curious to know if there exists a method to adhere to this pattern using Drizzle, or if it would be advisable for me to reconsider my approach.

Thanks!
Was this page helpful?