BackendStorage #

Available since 2.8.0

The BackendStorage class allows to interact directly with the storage engine (Elasticsearch by default).

It is accessible from the Backend.storage property.

See the Data Storage guide.

storageClient #

TypeDescriptionget / set
any
Lazily instantiated client of the storage engineget
Available since 2.61.0

The client is built by the storage driver in use: the Elasticsearch client of the configured version with the built-in drivers, the driver's own engine client when services.storageEngine.driver is set, whatever majorVersion says. The driver's TypeScript page (e.g. kuzzle-storage-es-9) tells its API and how to type it. getEngine() tells which driver is in use.

Usage #

With the Elasticsearch 7 client (also the shape of the OpenSearch drivers' client):

const esRequest =  {
  body: {
    name: 'Aschen',
    age: 27
  },
  index: '&nyc-open-data.yellow-taxi',
  op_type: 'create'
}

await app.storage.storageClient.index(esRequest)

StorageClient #

TypeDescriptionget / set
new (clientConfig?: any) => any
Storage client constructorget

It builds a new client of the same kind as storageClient, through the storage driver in use.

By default, the instantiated client uses the same configuration than the one used by Kuzzle.
It's possible to overload the client configuration by passing the clientConfig argument to the constructor.

Usage #

With the Elasticsearch 7 client (also the shape of the OpenSearch drivers' client):

const esRequest =  {
  body: {
    name: 'Aschen',
    age: 27
  },
  index: '&nyc-open-data.yellow-taxi',
  op_type: 'create'
}

// Instantiate and use a new client
const storageClient = new app.storage.StorageClient()
await storageClient.index(esRequest)