JSPM

@travetto/model-elasticsearch

1.0.0-beta.10
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q102449F
  • License MIT

Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.

Package Exports

  • @travetto/model-elasticsearch

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@travetto/model-elasticsearch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

travetto: Model-Elasticsearch

Install: Elasticsearch provider

$ npm install @travetto/model-elasticsearch

This module provides an elasticsearch-based implementation of ModelSource for the Model module. This source allows the Model module to read, write and query against elasticsearch. In development mode, the ModelSource will also modify the elasticsearch schema in real time to minimize impact to development.

Out of the box, by installing the module, everything should be wired up by default. If you need to customize any aspect of the source or config, you can override and register it with the Dependency Injection module.

Code: Wiring up the Elasticsearch Model Source

export class Init {
  @InjectableFactory()
  static getModelSource(conf: ElasticsearchModelConfig): ModelSource {
    return new ElasticsearchModelSource(conf);
  }
}

where the ElasticsearchModelConfig is defined by:

Code: Structure of ElasticsearchModelConfig

@Config('elasticsearch.model')
export class ElasticsearchModelConfig {
  hosts = ['127.0.0.1'];
  port = 9200;
  options = {};
  namespace = 'app';
  indexCreate = {
    ...
  }
}

and can be overridden via environment variables or config files, as defined in Config.

NOTE During testing, the source will automatically spin up an elasticsearch server via a docker container if you are not already running the service.