npm drizzle-orm 0.21.1

latest releases: 0.36.1-bc6e8f5, 0.36.1, 0.36.0-96d338b...
20 months ago
  • 🎉 Added support for HAVING clause

  • 🎉 Added support for referencing selected fields in .where(), .having(), .groupBy() and .orderBy() using an optional callback:

    await db
      .select({
        id: citiesTable.id,
        name: sql<string>`upper(${citiesTable.name})`.as('upper_name'),
        usersCount: sql<number>`count(${users2Table.id})::int`.as('users_count'),
      })
      .from(citiesTable)
      .leftJoin(users2Table, eq(users2Table.cityId, citiesTable.id))
      .where(({ name }) => sql`length(${name}) >= 3`)
      .groupBy(citiesTable.id)
      .having(({ usersCount }) => sql`${usersCount} > 0`)
      .orderBy(({ name }) => name);

Don't miss a new drizzle-orm release

NewReleases is sending notifications on new releases.