trying to use $count withing query relational api

PostgresError: column projects.project_id does not exist
const projectsInQueueWithDrizzle = await db.query.projects.findMany({
    with: {
      matches: true,
    },
    extras: ({ id: projectId }) => ({
      matchCount: db
        .$count(matches, eq(matches.projectId, projectId))
        .as("matchCount"),
    }),
  });
Was this page helpful?