sphinxql
Version:
SphinxQL query builder for Node.JS. Supports Sphinx search(2.x and 3.x) and Manticore search
36 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var yallist = require("yallist");
var Queue = (function () {
function Queue(connection) {
this.connection = connection;
this.list = yallist.create([]);
}
Queue.prototype.push = function (statement) {
this.list.push(statement);
return this;
};
Queue.prototype.shift = function () {
return this.list.shift();
};
Queue.prototype.size = function () {
return this.list.length;
};
Queue.prototype.empty = function () {
return this.size() === 0;
};
Queue.prototype.joinQueries = function () {
var sqlStrings = this.list.toArray().map(function (query) { return query.generate(); });
return sqlStrings.join(';');
};
Queue.prototype.process = function () {
if (!this.list.length) {
return Promise.reject(new Error('Empty list can not be joined'));
}
var sql = this.joinQueries();
return this.connection.query(sql);
};
return Queue;
}());
exports.default = Queue;
//# sourceMappingURL=Queue.js.map