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 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,
        },
      },
    },
  })

Thanks
Was this page helpful?