Core
Write Plugins v1.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.

storage #

Initializes the plugin's private data storage.

Data stored in this space can only be accessed by their proprietary plugin, using the Repository constructor.

The only way documents stored in this space can be accessed using Kuzzle is if the plugin voluntarily exposes that data by adding new API routes.


bootstrap #

Initializes the plugin storage.

Can be called any number of times as long as identical mappings are provided.

Arguments #

Copied to clipboard!
bootstrap(collections);

Arguments Type Description
collections
object
List of collection to create, with their corresponding data mapping

Return #

The bootstrap function returns a promise, resolving once the storage is initialized.

Example #

Copied to clipboard!
const mappings = {
  collection1: {
    properties: {
      someField: {
        type: 'keyword'
      }
    }
  },
  collection2: {
    properties: {
      // ...
    }
  }
};

try {
  await context.accessors.storage.bootstrap(mappings);
} catch (error) {
  // "error" is a KuzzleError object
}

createCollection #

Creates a collection in the plugin storage.

Can be called any number of times as long as the mapping is not modified.

Arguments #

Copied to clipboard!
createCollection(collection, mapping);

Arguments Type Description
collection
string
Collection name
mapping
object
Collection mapping

Return #

The createCollection function returns a promise.

Example #

Copied to clipboard!
const mapping = {
  properties: {
    someField: {
      type: 'keyword'
    }
  }
};

try {
  await context.accessors.storage.createCollection('collection1', mapping);
} catch (error) {
  // "error" is a KuzzleError object
}