© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
2 replies
BiffBaffBoff

Aggregation with Query API

Hi, is it possible to do aggregation via the query API? I have to do the following at the moment, then I do a
form.submissions.length
form.submissions.length
to get the current count. Can it be simplified?
const res = await db.query.formsTbl.findMany({
    where: (forms, { eq }) => eq(forms.createdBy, user.userId),
    with: {
      submissions: {
        columns: {
          id: true,
        },
      },
    },
  })
const res = await db.query.formsTbl.findMany({
    where: (forms, { eq }) => eq(forms.createdBy, user.userId),
    with: {
      submissions: {
        columns: {
          id: true,
        },
      },
    },
  })

Thanks
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Joins with the Query API
Drizzle TeamDTDrizzle Team / help
2y ago
Custom aggregation column types
Drizzle TeamDTDrizzle Team / help
2y ago
Query API Returned Structure
Drizzle TeamDTDrizzle Team / help
15mo ago
query with
Drizzle TeamDTDrizzle Team / help
2y ago