cassandra-cql-builder
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "cassandra-cql-builder", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Cassandra CQL Builder", | ||
@@ -11,3 +11,4 @@ "main": "dist/index.js", | ||
"test": "jest --forceExit", | ||
"build": "webpack" | ||
"build": "webpack", | ||
"lint": "eslint ./src" | ||
}, | ||
@@ -46,8 +47,10 @@ "jest": { | ||
"devDependencies": { | ||
"babel-jest": "^19.0.0", | ||
"babel-loader": "^6.4.1", | ||
"@ridi/eslint-config": "*", | ||
"babel-jest": "^20.0.3", | ||
"babel-loader": "^7.1.1", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.0", | ||
"jest": "^19.0.2", | ||
"webpack": "^2.3.2" | ||
"eslint": "^4.5.0", | ||
"jest": "^20.0.4", | ||
"webpack": "^3.5.5" | ||
} | ||
} |
149
README.md
# cql-builder | ||
Cassandra CQL Builder | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/ridibooks/cql-builder.svg)](https://greenkeeper.io/) | ||
Simple Cassandra CQL Builder in Javascript | ||
## Installation | ||
``` | ||
$ npm install --save cassandra-cql-builder | ||
``` | ||
## Usage | ||
```javascript | ||
import { Insert, Select, Update, Delete, CqlBuilderError } from 'cassandra-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 | ||
```javascript | ||
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 | ||
```javascript | ||
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) | ||
.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 ?' | ||
// 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) | ||
### Update | ||
Generate update query | ||
```javascript | ||
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 | ||
```javascript | ||
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 git@github.com:ridibooks/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 | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17728
150
0
7