npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-cassandra-querybuilder

v1.0.2

Published

this project provides a QueryBuilder for Apache Cassandra to NodeJS

Downloads

15

Readme

node-cassandra-querybuilder

Apache Cassandra QueryBuilder for NodeJS

this project provides a QueryBuilder for Apache Cassandra to NodeJS

Installation

$ npm install --save node-cassandra-querybuilder

Basic Usage

var QueryBuilder = require('node-cassandra-querybuilder');
var query = QueryBuilder
        .select() // choose statement
        .columns(['*']) // select columns to be projected
        .from('db', 'table') // select database and table
        .where(QueryBuilder.eq('foo', 'bar')) // add condition
        .limit(5) // add limit
        .toString(); // compile and get query
console.log(query); // SELECT * FROM db.table WHERE foo = 'bar';

Documentation

Statements

  • QueryBuilder.select() - call select statement
  • QueryBuilder.insert() - call insert statement
  • QueryBuilder.update() - call update statement
  • QueryBuilder.delete() - call delete statement
var select = QueryBuilder.select() //or...
QueryBuilder.select()...

Operators

{column} - name of the column {value} - value to be recorded

  • QueryBuilder.eq({column}, {value}) - equal operator
  • QueryBuilder.lt({column}, {value}) - less than operator
  • QueryBuilder.lte({column}, {value}) - less than or equal operator
  • QueryBuilder.gt({column}, {value}) - greater than operator
  • QueryBuilder.gte({column}, {value}) - greater than or equal operator
QueryBuilder.gte('size', 10) // size >= 10

UUID type needs wrapper to works

QueryBuilder.eq('id', new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68')) // id = 652f2270-fac4-11e5-bcc3-452e2b89ab68

Conditions

{operator} - Operators type

  • where({operator}) - insert condition
  • and({operator}) - append condition
...where(QueryBuilder.eq('foo', 'bar')) // WHERE foo = 'bar'
...where(QueryBuilder.eq('foo', 'bar')).and(QueryBuilder.lte('length', 10)) // WHERE foo = 'bar' AND length <= 10

Modifiers

{limiter} - value to limit

  • limit({limiter}) - add limit
...where(QueryBuilder.eq('foo', 'bar')).limit(5) // WHERE foo = 'bar' LIMIT 5

Utils

{database} - database name {table} - table name {columns} - array of columns' names {values} - array of values to be recorded {operator} - Operators type

  • from([{database, }] {table}) - set database's name and/or table's name
  • columns({columns}) - set columns
  • values({values}) - set values
  • set({operator}) - set assignment
...from('database','table') // database.table
...from('table') // table
...columns(['id', 'name', 'age']) // (id,name,age)
...values([new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68'),'foo',99]) // (652f2270-fac4-11e5-bcc3-452e2b89ab68, 'foo', 99)
...set(QueryBuilder.eq('name', 'foo')).set(QueryBuilder.eq('age', 99)) // name = 'foo', age = 99

Examples

// SELECT id,name,age FROM db.users WHERE id = 652f2270-fac4-11e5-bcc3-452e2b89ab68 AND age < 50 LIMIT 1;
QueryBuilder
        .select()
        .columns(['id', 'name', 'age'])
        .from('db', 'users')
        .where(QueryBuilder.eq('id', new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68')))
        .and(QueryBuilder.lt('age', 50))
        .limit(1)
        .toString();

// INSERT INTO db.users (id,name,age) VALUES (652f2270-fac4-11e5-bcc3-452e2b89ab68,'foo',70);
QueryBuilder
        .insert()
        .from('db', 'users')
        .columns(['id', 'name', 'age'])
        .values([new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68'), 'foo', 70])
        .toString();

// UPDATE db.users SET name = 'foo bar', age = 71 WHERE id = 652f2270-fac4-11e5-bcc3-452e2b89ab68;
QueryBuilder
        .update()
        .from('db', 'users')
        .set(QueryBuilder.eq('name', 'foo bar'))
        .set(QueryBuilder.eq('age', 71))
        .where(QueryBuilder.eq('id', new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68')))
        .toString();

// DELETE FROM db.users WHERE id = 652f2270-fac4-11e5-bcc3-452e2b89ab68;
QueryBuilder
        .delete()
        .from('db', 'users')
        .where(QueryBuilder.eq('id', new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68')))
        .toString();

Tips

you can use statements as an attribute too (is better to make code conditions)

function(age_value) {
	var select = QueryBuilder.select();
	select.columns(['id', 'name', 'age']).from('db', 'users')
        .where(QueryBuilder.eq('id', new QueryBuilder.Types.UUID('652f2270-fac4-11e5-bcc3-452e2b89ab68')))

	if (age_value) {
		select.and(QueryBuilder.lt('age', 50));
	}

	return select.toString();
};

use '*' to select all columns

...columns(['*'])...

Contributors

Jean Vasconcelos