Skip to content

Commit 1a79928

Browse files
author
Travis CI
committed
Travis CI - [ci skip] - automatic dist folder
1 parent 92e9047 commit 1a79928

File tree

3 files changed

+85
-11
lines changed

3 files changed

+85
-11
lines changed

dist/kuzzle.js

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ module.exports = Kuzzle = function (url, options, cb) {
529529
return this.bluebird.promisifyAll(this, {
530530
suffix: 'Promise',
531531
filter: function (name, func, target, passes) {
532-
var whitelist = ['getAllStatistics', 'getStatistics', 'listCollections', 'now', 'query'];
532+
var whitelist = ['getAllStatistics', 'getServerInfo', 'getStatistics', 'listCollections', 'listIndexes', 'now', 'query'];
533533

534534
return passes && whitelist.indexOf(name) !== -1;
535535
}
@@ -961,16 +961,39 @@ Kuzzle.prototype.flushQueue = function () {
961961
/**
962962
* Returns the list of known persisted data collections.
963963
*
964+
* @param {string} [index] - Index containing collections to be listed
964965
* @param {object} [options] - Optional parameters
965966
* @param {responseCallback} cb - Handles the query response
966967
* @returns {object} this
967968
*/
968-
Kuzzle.prototype.listCollections = function (options, cb) {
969-
var collectionType = 'all';
969+
Kuzzle.prototype.listCollections = function () {
970+
var
971+
collectionType = 'all',
972+
index,
973+
options,
974+
cb,
975+
args = Array.prototype.slice.call(arguments);
976+
977+
args.forEach(function(arg) {
978+
switch (typeof arg) {
979+
case 'string':
980+
index = arg;
981+
break;
982+
case 'object':
983+
options = arg;
984+
break;
985+
case 'function':
986+
cb = arg;
987+
break;
988+
}
989+
});
970990

971-
if (!cb && typeof options === 'function') {
972-
cb = options;
973-
options = null;
991+
if (!index) {
992+
if (!this.defaultIndex) {
993+
throw new Error('Kuzzle.listCollections: index required');
994+
}
995+
996+
index = this.defaultIndex;
974997
}
975998

976999
this.callbackRequired('Kuzzle.listCollections', cb);
@@ -979,7 +1002,7 @@ Kuzzle.prototype.listCollections = function (options, cb) {
9791002
collectionType = options.type;
9801003
}
9811004

982-
this.query({controller: 'read', action: 'listCollections'}, {body: {type: collectionType}}, options, function (err, res) {
1005+
this.query({index: index, controller: 'read', action: 'listCollections'}, {body: {type: collectionType}}, options, function (err, res) {
9831006
if (err) {
9841007
return cb(err);
9851008
}
@@ -990,6 +1013,32 @@ Kuzzle.prototype.listCollections = function (options, cb) {
9901013
return this;
9911014
};
9921015

1016+
/**
1017+
* Returns the list of existing indexes in Kuzzle
1018+
*
1019+
* @param {object} [options] - Optional arguments
1020+
* @param {responseCallback} cb - Handles the query response
1021+
* @returns {object} this
1022+
*/
1023+
Kuzzle.prototype.listIndexes = function (options, cb) {
1024+
if (!cb && typeof options === 'function') {
1025+
cb = options;
1026+
options = null;
1027+
}
1028+
1029+
this.callbackRequired('Kuzzle.listIndexes', cb);
1030+
1031+
this.query({controller: 'read', action: 'listIndexes'}, {}, options, function (err, res) {
1032+
if (err) {
1033+
return cb(err);
1034+
}
1035+
1036+
return cb(null, res.result.indexes);
1037+
});
1038+
1039+
return this;
1040+
};
1041+
9931042
/**
9941043
* Disconnects from Kuzzle and invalidate this instance.
9951044
*/
@@ -1009,6 +1058,32 @@ Kuzzle.prototype.disconnect = function () {
10091058
}
10101059
};
10111060

1061+
/**
1062+
* Returns the server informations
1063+
*
1064+
* @param {object} [options] - Optional arguments
1065+
* @param {responseCallback} cb - Handles the query response
1066+
* @returns {object} this
1067+
*/
1068+
Kuzzle.prototype.getServerInfo = function (options, cb) {
1069+
if (!cb && typeof options === 'function') {
1070+
cb = options;
1071+
options = null;
1072+
}
1073+
1074+
this.callbackRequired('Kuzzle.getServerInfo', cb);
1075+
1076+
this.query({controller: 'read', action: 'serverInfo'}, {}, options, function (err, res) {
1077+
if (err) {
1078+
return cb(err);
1079+
}
1080+
1081+
cb(null, res.result.serverInfo);
1082+
});
1083+
1084+
return this;
1085+
};
1086+
10121087
/**
10131088
* Return the current Kuzzle's UTC Epoch time, in milliseconds
10141089
* @param {object} [options] - Optional parameters
@@ -1182,7 +1257,6 @@ Kuzzle.prototype.replayQueue = function () {
11821257
return this;
11831258
};
11841259

1185-
11861260
/**
11871261
* Sets the default Kuzzle index
11881262
*

0 commit comments

Comments
 (0)