{"action":"closed","issue":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1023","labels_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1023/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1023/comments","events_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1023/events","html_url":"https://github.com/tgriesser/bookshelf/issues/1023","id":116682606,"number":1023,"title":"How to properly use count()","user":{"login":"mezod","id":1230963,"avatar_url":"https://avatars.githubusercontent.com/u/1230963?v=3","gravatar_id":"","url":"https://api.github.com/users/mezod","html_url":"https://github.com/mezod","followers_url":"https://api.github.com/users/mezod/followers","following_url":"https://api.github.com/users/mezod/following{/other_user}","gists_url":"https://api.github.com/users/mezod/gists{/gist_id}","starred_url":"https://api.github.com/users/mezod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mezod/subscriptions","organizations_url":"https://api.github.com/users/mezod/orgs","repos_url":"https://api.github.com/users/mezod/repos","events_url":"https://api.github.com/users/mezod/events{/privacy}","received_events_url":"https://api.github.com/users/mezod/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-11-13T01:53:50Z","updated_at":"2015-11-13T13:10:51Z","closed_at":"2015-11-13T13:10:51Z","body":"I was trying to get something like ```Model.count('user_id', userId);``` to work but after trying several syntaxes I realized that count() might not be able to do what I expect it to do.\r\n\r\nRight now the only way to get something to work is to do: \r\n\r\n```Model.query().where({'user_id': userId}).count();```\r\n\r\nwhich is pretty ugly because it returns one row with a 'count' column so I have to do something like .then(rows => Number(rows[0].count)) which is horrible... how do you guys go about this?\r\n\r\nAdding an example to the API would be cool :P "}}