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 #
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 #
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 #
createCollection(collection, mapping);
Arguments | Type | Description |
---|---|---|
collection | string | Collection name |
mapping | object | Collection mapping |
Return #
The createCollection
function returns a promise.
Example #
const mapping = {
properties: {
someField: {
type: 'keyword'
}
}
};
try {
await context.accessors.storage.createCollection('collection1', mapping);
} catch (error) {
// "error" is a KuzzleError object
}