Reputation: 23
How I can write query with Objection.js?
SELECT AVG(field), COUNT(*) FROM tab
Please help me
Upvotes: 2
Views: 804
Reputation: 275
Try this:
const result = await Tab.query().avg(`field`).count(`*`)
console.log(result[0].avg, result[0].count)
Upvotes: 2