-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
34 lines (25 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var QueryBuilder = require('./lib/querybuilder'),
vargs = require('vargs-callback');
var Cassandra = function () {
this.client = null;
};
Cassandra.prototype.setClient = function (client) {
this.client = client;
};
Cassandra.prototype.InsertQuery = function (keyspace, client, consistency) {
return new QueryBuilder(1, keyspace, client || this.client, consistency);
};
Cassandra.prototype.UpdateQuery = function (keyspace, client, consistency) {
return new QueryBuilder(2, keyspace, client || this.client, consistency);
};
Cassandra.prototype.SelectQuery = function (keyspace, client, consistency) {
return new QueryBuilder(3, keyspace, client || this.client, consistency);
};
Cassandra.prototype.DeleteQuery = function (keyspace, client, consistency) {
return new QueryBuilder(4, keyspace, client || this.client, consistency);
};
Cassandra.prototype.batch = vargs(function (queries, client, next) {
client = client || this.client;
client.batch(queries.map(function (query) { return query.dump() }), { prepare: true }, next);
});
module.exports = new Cassandra();