Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4.0 to 1.5.0

4

componentDeclarations/componentBuilderMethods.js

@@ -44,4 +44,4 @@ /**

"query": {
"from": {"name": "table", "grouping": "source"},
"into": {"name": "table", "grouping": "source"},
"from": {"name": "from", "grouping": "source"},
"into": {"name": "into", "grouping": "source"},

@@ -48,0 +48,0 @@ "where": {"name": "where", "grouping": "where"},

{
"name": "cassanknex",
"version": "1.4.0",
"version": "1.5.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",

@@ -24,2 +24,5 @@ /**

return this._wrapMethod(component, "update", _getUpdate(), arguments);
},
delete: function () {
return this._wrapMethod(component, "delete", _getDelete(), arguments);
}

@@ -135,2 +138,25 @@ };

function _getDelete() {
return function () {
var compiling = this.getCompiling("delete", {
columns: _.toArray(arguments)
});
var source = (this._keyspace && this._columnFamily ? [this._keyspace, this._columnFamily].join(".") : (this._columnFamily ? this._columnFamily : ""))
, deleteStatement = "DELETE " + compiling.value.columns.join(",") + " FROM " + source
, cql = deleteStatement;
if (_.has(this._grouped, "where")) {
cql += " WHERE " + _compileWhere(this, this._grouped.where);
}
this.query({
cql: cql + ";"
});
return this;
};
}
// helper compilers

@@ -137,0 +163,0 @@

@@ -130,4 +130,2 @@

While fuller documentation for all methods is in the works, **the [test files](./tests) provide thorough examples as to method usage**.
#### <a name="Quickstart"></a>Quickstart

@@ -243,2 +241,4 @@

> While fuller documentation for all methods is in the works, **the [test files](./tests) provide thorough examples as to method usage**.
#### <a name="QueryCommands"></a>Query Commands

@@ -318,2 +318,4 @@

- 1.5.0
- Add QueryCommand `delete`.
- 1.4.0

@@ -320,0 +322,0 @@ - Add support for object style `set` calls; e.g. `.set(<Object := {<String>: <Mixed>, ...}>)`.

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

"build a sample table and execute several insertions into that table, " +
"and read records inserted using both the 'exec' and 'stream' and 'eachRow' methods.", function (done) {
"and read records inserted using both the 'exec' and 'stream' and 'eachRow' methods" +
" - then delete all rows from the test table.", function (done) {

@@ -152,2 +153,45 @@ this.timeout(0);

qb.eachRow(rowCallback, errorCb);
},
// test the delete method
function (next) {
async.waterfall([
function (next) {
var qb = cassanKnex(keyspace)
.select()
.from(columnFamily)
.exec(function (err, resp) {
assert(!err, err);
next(err, resp.rows);
});
},
function (rows, next) {
async.each(rows, function (row, done) {
var qb = cassanKnex(keyspace)
.delete()
.from(columnFamily)
.where("id", "=", row.id)
.andWhere("timestamp", "=", row.timestamp)
.exec(function (err, resp) {
assert(!err, err);
done(err);
});
}, next);
}
], next);
},
// confirm the delete worked
function (next) {
var qb = cassanKnex(keyspace)
.select()
.from(columnFamily)
.exec(function (err, resp) {
assert(!err, err);
assert(resp.rowLength === 0, "All rows must be deleted!");
next(err);
});
}

@@ -154,0 +198,0 @@ ], function (err) {

@@ -13,2 +13,5 @@ /**

describe("QueryMethods", function () {
// SELECT
it("should compile an insert query string", function () {

@@ -112,2 +115,5 @@

});
// UPDATE
it("should compile an update query string", function () {

@@ -152,2 +158,42 @@

});
// DELETE
it("should compile a simple delete query string", function () {
var cql = "DELETE FROM cassanKnexy.columnFamily WHERE foo[bar] = ? AND id in (?, ?, ?, ?, ?);"
, qb = cassanKnex("cassanKnexy");
qb.delete()
.from("columnFamily")
.where("foo[bar]", "=", "baz")
.where("id", "in", ["1", "1", "2", "3", "5"]);
var _cql = qb.cql();
assert(_cql === cql, "Expected compilation: '" + cql + "' but compiled: " + _cql);
});
it("should compile a delete columns query string", function () {
var cql = "DELETE foo,bar FROM cassanKnexy.columnFamily WHERE foo[bar] = ? AND id in (?, ?, ?, ?, ?);"
, qb = cassanKnex("cassanKnexy");
qb.delete("foo", "bar")
.from("columnFamily")
.where("foo[bar]", "=", "baz")
.where("id", "in", ["1", "1", "2", "3", "5"]);
var _cql = qb.cql();
assert(_cql === cql, "Expected compilation: '" + cql + "' but compiled: " + _cql);
});
it("should compile a delete columns query string using an array as input", function () {
var cql = "DELETE foo,bar FROM cassanKnexy.columnFamily WHERE foo[bar] = ? AND id in (?, ?, ?, ?, ?);"
, qb = cassanKnex("cassanKnexy");
qb.delete(["foo", "bar"])
.from("columnFamily")
.where("foo[bar]", "=", "baz")
.where("id", "in", ["1", "1", "2", "3", "5"]);
var _cql = qb.cql();
assert(_cql === cql, "Expected compilation: '" + cql + "' but compiled: " + _cql);
});
});
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