zbrox zbrox - 1 year ago 148
Node.js Question

bookshelf.js count method

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 it just used with a manual select query?


Answer Source

For now it's a manual query... e.g:


Long story as to why that's the case, but it's mainly because of a few complexities around counts in relations, I don't want to hack a half working one on there just for the sake of having it there for the time being... the ultimate solution is going to be to have:


But currently that mutates the knex query builder instance, so doesn't quite work. I've been working on a big refactor of knex and I'm looking to get this implemented in the near future.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download