countPromise = this.query().clone().transacting(options.transacting).select(
bookshelf.knex.raw('count(distinct ’ + tableName + ‘.’ + idAttribute + ‘) as aggregate’));
I’m looking at this line of code and I’m curious as to why since we a model we don’t just count all the records like so:
countPromise = this.query().clone().select(count(*) FROM ${tableName} as aggregate
)
Is there a reason knex.raw is used? Thanks.