I was searching high and low to find how to do basic counting (like SELECT COUNT(something) FROM table) with Bookshelf.js, but to no avail. Is there anything I\'m missing? Or is
//user.js
var db = require('./db');
var User = db.Model.extend({
tableName: 'users',
hasTimestamps: true,
});
module.exports = User;
//main.js
var User = require('./user');
User.where('pet', 'dog').count('*').then(function(count) {
console.log("Total Count : " , count);
});
In the above code snippet User is a model having the attributes like pet and name.
The generated query will be as follows: select count(*) from user where pet='dog';