Hey all! I'd like to explore the possibility to order a query by one of it's columns, but the column itself is inferred from a variable. What i've tried:
// "categories" has 2 column, id and nameconst sortField = 'name';await db.query.categories.findMany({ orderBy: asc(sql`${sortField}`) });
// "categories" has 2 column, id and nameconst sortField = 'name';await db.query.categories.findMany({ orderBy: asc(sql`${sortField}`) });
but no sort is applied.
Even using
const sortField = 'name' as keyof typeof categories;
const sortField = 'name' as keyof typeof categories;