Socket
Socket
Sign inDemoInstall

fcql

Package Overview
Dependencies
4
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fcql

Fluent syntax for Apache Cassandra CQL


Version published
Weekly downloads
4
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Fluent CQL (fcql)

Allows fluent syntax for Cassandra Query Language (cql). Basically it creates CQL string queries from JavaScript code.

NOTE! Only CQL3 is supported.

Example:

var stringQuery = fcql.select(['key', 'email', 'last_name'])
.from('user_profiles')
.where( { key: 'my_user' }).build();

results with

SELECT key, email, last_name
FROM user_profiles
WHERE key = 'my_user';

Also raw strings work:

var stringQuery = fcql.select('key, email, last_name')
.from('user_profiles')
.where('key="my_user"').build();

results the same as above.

For whom?

  • The library validates given parameters so that you do less mistakes and code faster.
  • The library helpful for CQL newbies. JSDoc supported functions will show you available options.
  • The library allows partial query reuse (DRY). You can store 'SELECT...FROM...' and then add 'WHERE' as new query needed.

Usage

var fcql = require('fcql');

Creating tables

fcql.create().table('my_mega_table', {
  name: fcql.text, // allows usage of both hardcoded ('text') and/or fcql-provided CQL types
  eventDate: 'timestamp',
  device: fcql.uuid,
  sensor: 'int',
  description: 'text',
  PRIMARY_KEY: [ ['name', 'eventDate'], 'device', 'sensor' ]
}).build();

results with

CREATE TABLE my_mega_table (
  name text,
  eventDate timestamp,
  device uuid,
  sensor int,
  description text,
  PRIMARY KEY ((name, eventDate), device, sensor)
);

Querying for data

fcql.select('something').from('somewhere').where({
  aStringKey: {GT: '0', LE: '9'},
  anIntKey: 123,
  aDateKey: [new Date(3141592653589), new Date(2141592653589)]
});

results with

SELECT something FROM somewhere WHERE 
aStringKey > '0' AND aStringKey <= '9' 
AND anIntKey = 123 
AND aDateKey IN ('2069-07-21T00:37:33.589Z', '2037-11-11T22:50:53.589Z');

Want to contribute?

It is Open Open Source. Whoever sends a PR, which gets accepted, receives the write permissions.

Keywords

FAQs

Last updated on 29 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc