Order by on Joined Tables

I am attempting to do an order by for a joined table

export const playerItem = pgTable(
  "playerItem",
  {
    id: uuid()
      .primaryKey()
      .default(sql`gen_random_uuid()`),
    playerId: uuid().references(() => player.id),
    ...defaultColumns,
  },
  (t) => [index("player_item_pk_index").on(t.id)],
)
export const player = pgTable(
  "player",
  {
    id: uuid()
      .primaryKey()
      .default(sql`gen_random_uuid()`),
    fullName: text().notNull(),
    firstName: text().notNull(),
    lastName: text().notNull(),

    ...defaultColumns,
  },
  (t) => [index("player_pk_index").on(t.id)],
)


I want to query playerItem with an order by on player.lastName descending. I don't see any examples in the documentation on how to do this or if Drizzle allows it.

This is a simplified example of the schema, denormalizing would make sense here, but I purposely excluded the rest of the columns/relations to make reading easier

Any help would be appreciated!
Was this page helpful?