I have a route that returns statistics about quotes such as total estimate, total quotes and total quote where complete is true or not true.
function totalCount() {
return db('quotes')
.count('is_complete', {as: 'total_complete'})
.count('is_complete')
.sum('estimate', {as: 'estimate_total'})
.first()
The issue I am having it getting the where clause into my knex query. If it try to set a where clause the beginning of the query, it affects the whole query.
My where clause is where is_complete = true