use `count` in db.query?

export function queryQuestions() {
return db.query.questionsTable.findMany({
limit: 5,
orderBy: ({ createdAt }, { desc }) => desc(createdAt),
with: {
author: true,
answers: {
extras: //
}
},
})
}
export function queryQuestions() {
return db.query.questionsTable.findMany({
limit: 5,
orderBy: ({ createdAt }, { desc }) => desc(createdAt),
with: {
author: true,
answers: {
extras: //
}
},
})
}
I am not fully understanding the API, require support
Solution:
https://orm.drizzle.team/docs/rqb#include-custom-fields As of now aggregations are not supported in extras...
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Jump to solution
2 Replies
piscopancer
piscopancerOP10mo ago
I need to count the number of answers
Solution
Mykhailo
Mykhailo10mo ago
https://orm.drizzle.team/docs/rqb#include-custom-fields As of now aggregations are not supported in extras
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server