SDK
SDK Javascript v7.x
2

list #

Returns the list of collections associated to a provided index. The returned list is sorted in alphanumerical order.


list(index, [options]);

ArgumentsTypeDescription
index
string
Index name
options
object
Query options

options #

Additional query options

PropertyType
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again
from
number

(0)
Offset of the first result
Deprecated since 7.1.4
size
number

(10)
Maximum number of returned results
Deprecated since 7.1.4
timeout
number

(-1)
Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely
triggerEvents
boolean

(false)
If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop.
Available since Kuzzle 2.31.0

Resolves #

Resolves to an object containing the following properties:

PropertyTypeDescription
type
string
Types of returned collections
(all, realtime or stored)
collections
object[]
List of collections
from
number
Offset of the first result
Deprecated since 7.1.4
size
number
Maximum number of returned results
Deprecated since 7.1.4

Each object in the collections array contains the following properties:

PropertyTypeDescription
name
string
Collection name
type
string
Collection type (realtime or stored)

Usage #

try {
  const options = { from: 1, size: 1 };
  const collectionList = await kuzzle.collection.list('mtp-open-data', options);
  console.log(collectionList);
  /*
    {
      type: 'all',
      collections: [ { name: 'pink-taxi', type: 'stored' } ],
      from: 1,
      size: 1
    }
  */
  console.log('Success');
} catch (error) {
  console.error(error.message);
}