SDK
SDK Javascript v5.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

listCollections #

Returns the list of known collections contained in a specified index.


listCollections([index], [options], callback) #

ArgumentsTypeDescription
indexstringIndex containing the collections to be listed
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Options #

OptionTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue
fromintegerDetermines the starting point of the pagination. By default, start at the beggining0
sizeintegerDetermines the size of the returned result set. By default, no limit is appliedundefined
typestringGet either stored collections or realtime ones. By default, list all collectionsall

If no index argument is provided, the defaultIndex property is used. If no default index is found, this method throws an error.


Callback Response #

Returns an array of JSON objects containing the list of stored and/or realtime collections on the provided index.

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle.listCollections('index', {type: 'stored', from: 0, size: 42}, function (err, collections) {
  // ...
});
// Using promises (NodeJS only)
kuzzle
  .listCollectionsPromise('index', {type: 'stored'})
  .then(collections => {
    // ...
  });

Callback response:

[
  { "name": "realtime_1", "type": "realtime" },
  { "name": "realtime_2", "type": "realtime" },
  { "name": "realtime_...", "type": "realtime" },
  { "name": "realtime_n", "type": "realtime" },
  { "name": "stored_1", "type": "stored" },
  { "name": "stored_2", "type": "stored" },
  { "name": "stored_...", "type": "stored" },
  { "name": "stored_n", "type": "stored" }
]