Bug: Count in Extras (Relational)

Trying to use the example from: https://orm.drizzle.team/docs/query-utils#count

const results = await context.db.query.label.findMany({
        extras: {
          postsCount: context.db.$count(danceLabel, eq(danceLabel.labelId, label.id)).as("postsCount"),
        },

        limit: input.limit,
        offset: input.offset,
      });
      return results;



NeonDbError: column "danceId" does not exist


it seems like the output SQL query is WRONG -- it is attempting to match on label.danceId instead of label.id
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?