New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cassanknex

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cassanknex - npm Package Compare versions

Comparing version 1.7.1 to 1.8.0

.jshintrc

3

gruntfile.js

@@ -25,4 +25,3 @@ /**

options: {
node: true,
laxcomma: true
jshintrc: '.jshintrc'
}

@@ -29,0 +28,0 @@ }

@@ -13,3 +13,4 @@ /**

var cassandra = null;
var cassandra = null
, duckType = "[Object CassanKnex]";

@@ -20,2 +21,8 @@ function CassanKnex() {

/**
* Initializes a new CassanKnex object.
*
* @param config
* @returns {cassanKnex}
*/
CassanKnex.initialize = function (config) {

@@ -45,3 +52,9 @@

// create the exec function for a pass through to the datastax driver
/**
* Create the exec function for a pass through to the datastax driver.
*
* @param `{Object} options` optional argument passed to datastax driver upon query execution
* @param `{Function} cb` => function(err, result) {}
* @returns {Client|exports|module.exports}
*/
qb.exec = function (options, cb) {

@@ -78,3 +91,15 @@

// create the stream function for a pass through to the datastax driver
/**
* Create the stream function for a pass through to the datastax driver,
* all callbacks are defaulted to lodash#noop if not declared.
*
* @param `{Object} options` optional argument passed to datastax driver upon query execution
* @param `{Object} cbs` =>
* {
* readable: function() {},
* end: function() {},
* error: function(err) {}
* }
* @returns {Client|exports|module.exports}
*/
qb.stream = function (options, cbs) {

@@ -104,3 +129,10 @@

// create the eachRow function for a pass through to the datastax driver
/**
* Create the eachRow function for a pass through to the datastax driver.
*
* @param `{Object} options` optional argument passed to datastax driver upon query execution
* @param `{Function} rowCb` => function(row) {}
* @param `{Function} errorCb` => function(err) {}
* @returns {Client|exports|module.exports}
*/
qb.eachRow = function (options, rowCb, errorCb) {

@@ -135,2 +167,64 @@

/**
*
* @param options
* @param cassakni
* @param cb
* @returns {Client|exports|module.exports}
*/
qb.batch = function (options, cassakni, cb) {
var _options
, _cassakni
, _cb;
// options is really cassakni, cassakni is cb
if (_.isArray(options)) {
_options = {};
_cassakni = options;
_cb = cassakni;
}
// standard order
else {
_options = options;
_cassakni = cassakni;
_cb = cb;
}
if (!_.isFunction(_cb)) {
_cb = _.noop;
}
if (cassandra !== null && cassandra.connected) {
var error = null
, statements = _.map(_cassakni, function (qb) {
if (!qb.toString || qb.toString() !== duckType) {
error = new Error("Invalid input to CassanKnex#batch.");
return {};
}
else {
return {query: qb.cql(), params: qb.bindings()};
}
});
if (error) {
return _cb(error);
}
cassandra.batch(statements, _options, _cb);
}
else {
_cb(new Error("Cassandra client is not initialized."));
}
// maintain chain
return qb;
};
qb.toString = function () {
return duckType;
};
return qb;

@@ -149,3 +243,3 @@ }

cassanKnex.toString = function () {
return "[Object CassanKnex]";
return duckType;
};

@@ -152,0 +246,0 @@

{
"name": "cassanknex",
"version": "1.7.1",
"version": "1.8.0",
"description": "An Apache Cassandra CQL query builder with support for the DataStax NodeJS driver, written in the spirit of Knex.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@

An Apache Cassandra CQL query builder with support for the DataStax NodeJS driver, written in the spirit of [Knex][knexjs-url] for [CQL 3.1.x][cassandra-cql-3_1-ref-url].
A [fully tested][travis-url] Apache Cassandra CQL query builder with support for the DataStax NodeJS driver, written in the spirit of [Knex][knexjs-url] for [CQL 3.1.x][cassandra-cql-3_1-ref-url].

@@ -20,2 +20,6 @@ ## Index

- [Query Executors (Examples)](#QueryExecutors)
- [`exec`](#exec)
- [`eachRow`](#eachrow)
- [`stream`](#stream)
- [`batch`](#batch)
- [Query Commands (Examples)](#QueryCommands)

@@ -63,3 +67,4 @@ - [Rows](#QueryCommands-Rows)

Execution of a given query is performed by invoking either the `exec`, `stream` or `eachRow` methods
(which are straight pass throughs to the DataStax driver's `execute`, `stream` and `eachRow` [methods][cassandra-driver-docs-url], respectively).
(which are straight pass throughs to the DataStax driver's `execute`, `stream` and `eachRow` [methods][cassandra-driver-docs-url], respectively);
batch queries may be executed via the `batch` method (again, a pass through to the DataStax driver's own `batch` method).

@@ -132,2 +137,7 @@ ```js

qb.eachRow(rowCallback, errorCb);
// Invoke the batch method to process multiple requests
cassanKnex().batch([qb, qb], function(err, res) {
// do something w/ your response
});
});

@@ -255,4 +265,6 @@ ```

- exec - *execute a query and return the response via a callback*:
##### exec
- *execute a query and return the response via a callback*:
```js

@@ -275,4 +287,7 @@ var item = {

```
- eachRow - *execute a query and invoke a callback as each row is received*:
##### eachRow
- *execute a query and invoke a callback as each row is received*:
```js

@@ -293,4 +308,7 @@ var rowCallback = function (n, row) {

```
- stream - *execute a query and stream each row as it is received*:
##### stream
- *execute a query and stream each row as it is received*:
```js

@@ -323,2 +341,30 @@ var onReadable = function () {

##### batch
- *execute a batch of cassanknex queries in a single batch statement*:
```js
var qb1 = cassanKnex("cassanKnexy")
.insert({foo: "is bar"})
.usingTimestamp(250000)
.usingTTL(50000)
.from("columnFamily");
var qb2 = cassanKnex("cassanKnexy")
.insert({bar: "is foo"})
.usingTimestamp(250000)
.usingTTL(50000)
.from("columnFamily");
// w/o options
cassanKnex().batch([qb1, qb2], function(err, res) {
// do something w/ your err/result
});
// w/ options
cassanKnex().batch({prepare: true}, [qb1, qb2], function(err, res) {
// do something w/ your err/result
});
```
#### <a name="QueryCommands"></a>Query Commands

@@ -512,2 +558,4 @@

- 1.8.0
- Add `batch` execution functionality per the specifications laid out in issue [#19](https://github.com/azuqua/cassanknex/issues/19).
- 1.7.1

@@ -514,0 +562,0 @@ - Wrap all keyspace, column family, and column names in double quotes to preserve case per issue [#14](https://github.com/azuqua/cassanknex/issues/14).

@@ -89,3 +89,3 @@ /**

var items = _.map(Array(rows), function () {
var items = _.map(Array(rows).slice(25), function () {
var id = uuid.v4();

@@ -103,2 +103,18 @@ return {id: id, timestamp: new Date(), data: "", written: {keys: ["foo", "bar"], rando: id, dec: 42}};

},
// test batch method
function (next) {
var cassakni = _.map(Array(rows).slice(25), function () {
var id = uuid.v4()
, item = {id: id, timestamp: new Date(), data: "", written: {keys: ["foo", "bar"], rando: id, dec: 42}}
, qb = cassanKnex(keyspace)
.insert(item)
.into(columnFamily);
return qb;
});
cassanKnex().batch({prepare: true}, cassakni, next);
},
// test the execution method

@@ -105,0 +121,0 @@ function (next) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc