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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ridi/cql-builder

v1.0.4

Published

Cassandra CQL Builder

Downloads

17

Readme

cql-builder

npm Build Status Greenkeeper badge

Simple Cassandra CQL Builder in Javascript

Installation

$ npm install --save @ridi/cql-builder

Usage

import { Insert, Select, Update, Delete, CqlBuilderError } from '@ridi/cql-builder';

const result = Select().table('test_table', 'test_keyspace').build();

// Returns...
// result.query = 'SELECT * FROM test_keyspace.test_table'
// result.params = []

Insert

Generate insert query

const cql = Insert()
  .table('test_table', 'test_keyspace')
  .value('column1', 1)
  .option('TTL', 86400)
  .option('TIMESTAMP', 12345678)
  .build();

// Returns...
// cql.query = 'INSERT INTO test_keyspace.test_table (column1) VALUES (?) USING TTL ? AND TIMESTAMP ?'
// cql.params = [1, 86400, 12345678]

Methods

  • InsertBuilder.table(table, keyspace)
  • InsertBuilder.value(field, value)
  • InsertBuilder.option(option, value)

Select

Generate select query

const cql = Select()
    .table('test_table', 'test_keyspace')
    .field(['column1', 'column2'])
    .field('column3')
    .where('key1 = ?', 1000)
    .where('key2 > ?', 2000)
    .limit(5000)
    .order('key1 DESC')
    .where('key3 IN (?, ?)', 3000, 4000)
    .option('TTL', 86400)
    .filtering()
    .build();

// Returns...
// cql.query = 'SELECT column1, column2, column3 FROM test_keyspace.test_table WHERE key1 = ? AND key2 > ? AND key3 IN (?, ?) ORDER BY key1 DESC LIMIT ? ALLOW FILTERING'
// cql.params = [1000, 2000, 3000, 4000, 5000]

Methods

  • SelectBuilder.table(table, keyspace)
  • SelectBuilder.field(field)
  • SelectBuilder.where(where, values)
  • SelectBuilder.order(order)
  • SelectBuilder.limit(limit)
  • SelectBuilder.filtering(filtering = true)

Update

Generate update query

const cql = Update()
  .table('test_table')
  .set('column1', 1)
  .where('key1 = ?', 'a')
  .option('TTL', 3000)
  .upsert(true)
  .build();

// Returns...
// cql.query = 'UPDATE test_table USING TTL ? SET column1 = ? WHERE key1 = ?'
// cql.params = [3000, 1, 'a']

Methods

  • UpdateBuilder.table(table, keyspace)
  • UpdateBuilder.set(field, value)
  • UpdateBuilder.where(where, values)
  • UpdateBuilder.upsert(upsert)
  • UpdateBuilder.option(option, value)

Delete

Generate delete query

const cql = Delete()
  .table('test_table')
  .where('key1 = ?', 'a')
  .field(['column1', 'column2'])
  .option('TIMESTAMP', 12345678)
  .build();

// Returns...
// cql.query = 'DELETE column1, column2 FROM test_table USING TIMESTAMP ? WHERE key1 = ?'
// cql.params = [12345678, 'a']

Methods

  • DeleteBuilder.table(table, keyspace)
  • DeleteBuilder.field(field)
  • DeleteBuilder.where(where, values)
  • DeleteBuilder.option(option, value)

Development

$ git clone [email protected]:ridi/cql-builder.git
$ cd cql-builder
$ npm install

Build

Webpack build using Babel (Not required in development.)

$ npm run build

Test

Tests using Jest

$ npm test