cassanknex
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -26,4 +26,5 @@ /** | ||
"dropType": "dropType", | ||
"dropTypeIfExists": "dropTypeIfExists" | ||
"dropTypeIfExists": "dropTypeIfExists", | ||
"truncate": "truncate" | ||
}, | ||
@@ -30,0 +31,0 @@ "query": { |
{ | ||
"name": "cassanknex", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "An Apache Cassandra CQL query builder with support for the DataStax NodeJS driver, written in the spirit of Knex.", | ||
@@ -23,5 +23,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"cassandra-driver": "^2.0.1", | ||
"cassandra-driver": "^2.2.1", | ||
"inherits": "^2.0.1", | ||
"lodash": "^3.7.0" | ||
"lodash": "^3.10.1" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -10,2 +10,8 @@ | ||
## Installation | ||
``` | ||
npm install cassanknex | ||
``` | ||
## Index | ||
@@ -482,9 +488,10 @@ | ||
- createColumnFamilyIfNotExists | ||
- dropColumnFamily | ||
- dropColumnFamilyIfExists | ||
- createIndex | ||
- createType | ||
- createTypeIfNotExists | ||
- dropColumnFamily | ||
- dropColumnFamilyIfExists | ||
- dropType | ||
- dropTypeIfExists | ||
- truncate | ||
@@ -552,2 +559,4 @@ ##### <a name="QueryCommands-Keyspaces"></a>*For keyspace queries*: | ||
- 1.9.0 | ||
- Add `truncate` functionality. | ||
- 1.8.0 | ||
@@ -554,0 +563,0 @@ - Add `batch` execution functionality per the specifications laid out in issue [#19](https://github.com/azuqua/cassanknex/issues/19). |
@@ -98,2 +98,5 @@ /** | ||
return this._wrapMethod(component, "dropTypeIfExists", _getDropType(), arguments); | ||
}, | ||
truncate: function () { | ||
return this._wrapMethod(component, "truncate", _getTruncate(), arguments); | ||
} | ||
@@ -293,6 +296,8 @@ }; | ||
if (compiling.value.columnFamily) | ||
if (compiling.value.columnFamily) { | ||
this._setColumnFamily(compiling.value.columnFamily); | ||
if (compiling.value.keyspace) | ||
} | ||
if (compiling.value.keyspace) { | ||
this._setKeyspace(compiling.value.keyspace); | ||
} | ||
@@ -312,2 +317,29 @@ var dropStatement = compiling.value.ifNot ? "DROP TYPE IF EXISTS " : "DROP TYPE " | ||
function _getTruncate() { | ||
return function (columnFamily) { | ||
var compiling = this.getCompiling("truncate", { | ||
columnFamily: columnFamily | ||
}); | ||
if (compiling.value.columnFamily) { | ||
this._setColumnFamily(compiling.value.columnFamily); | ||
} | ||
if (compiling.value.keyspace) { | ||
this._setKeyspace(compiling.value.keyspace); | ||
} | ||
var truncateStatement = "TRUNCATE " + | ||
[formatter.wrapQuotes(this.keyspace()), formatter.wrapQuotes(this.columnFamily())].join(".") + | ||
" ;"; | ||
this.query({ | ||
cql: truncateStatement | ||
}); | ||
return this; | ||
}; | ||
} | ||
function _compileColumns(client, deliminator, wrap) { | ||
@@ -314,0 +346,0 @@ |
@@ -260,2 +260,14 @@ /** | ||
}); | ||
// TRUNCATE | ||
it("should compile a truncate column family statement", function () { | ||
var cql = 'TRUNCATE "cassanKnexy"."columnFamily" ;' | ||
, qb = cassanKnex("cassanKnexy") | ||
.truncate("columnFamily"); | ||
var _cql = qb.cql(); | ||
assert(_cql === cql, "Expected compilation: '" + cql + "' but compiled: " + _cql); | ||
}); | ||
}); |
@@ -246,2 +246,12 @@ /** | ||
}); | ||
}, | ||
// test the truncate execution | ||
function (next) { | ||
var qb = cassanKnex(keyspace) | ||
.truncate(columnFamily) | ||
.exec(function (err, resp) { | ||
assert(!err, err); | ||
next(err); | ||
}); | ||
} | ||
@@ -248,0 +258,0 @@ ], function (err) { |
103820
2372
596
Updatedcassandra-driver@^2.2.1
Updatedlodash@^3.10.1