- There is no exposed reference from the model to bookshelf (e.g. can't do something like
Ad.Bookshelf.knex
). Need to require the bookshelf instance itself.
// select count(*) from "ads" where "classified_id" = 2'
Ad.where({ classified_id: 2 })
.query() // <- returns QueryBuild instance
.count()
.then(function (count) {
console.log('\n***', count);
});