Raz
Raz
DTDrizzle Team
Created by Raz on 5/12/2025 in #help
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;
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
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
7 replies