Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to count? #30

Closed
ezsper opened this issue Oct 2, 2016 · 1 comment
Closed

How to count? #30

ezsper opened this issue Oct 2, 2016 · 1 comment

Comments

@ezsper
Copy link

ezsper commented Oct 2, 2016

qb("keyspace")
  .count('*')
  .where("id", "=", id)
  .limit(1)
  .from("database")
  .exec({ prepare: true })

.count is not a function

UnbounDev added a commit that referenced this issue Sep 8, 2017
Add 'count' aggregate, fixes #30
@UnbounDev
Copy link
Contributor

At long last, this is provided in v1.16.0; an example:

qb("keyspace")
  .select()
  .count('*')
  .where("id", "=", id)
  .limit(1)
  .from("database")
  .exec({ prepare: true })

NB! I highly recommend reviewing documentation on the count function in Cassandra as it has the potential to severely affect cluster performance (unless you happen to be using DSE Search against a Solr Core, in which case Solr is performing the count operation via Lucene indexes).

Ref: https://www.datastax.com/dev/blog/counting-keys-in-cassandra

...under the hood this is what the ‘select count’ query does too (with large enough limit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants