© 2026 Hedgehog Software, LLC
async function findProjectById(id: number) { return await db.query.projects.findFirst({ where: eq(projects.id, id), with: { ... matches:true }, extras: { matchesCount: db .$count(matches, eq(matches.projectId, projects.id)) .as("matchesCount"), }, });
project 1 >> { id: 1, matches: [], matchesCount: '2' }
project 1 >> { id: 1, matches: [], matchesCount: '0' }