One simple ORM used for ES 5./6. in order to easily manage your data.
All code resides under src/lib
folder.
Browse the examples section as it contains various cases. The ES connection is exposed therefore sky is the limit here, so you have a lot of flexibility.
Initiate an ES connection and expose it to the plugin.
Simple logger for internal usage. It supports various drivers which should implement logging methods present under the current console logger (lib/logger/console). The console logger is the default option. Also, you can use other external packages such as ain.
Object wrapper for an ES query - it supports everything you might think of based on your ES knowledge. Also, by passing the connection reference, all queries are executed at this point.
Bounds a model instance by it's index and desired type. For missing ids on indexing new documents, uuid are generated and used in the query. Another feature is that the Model class can be extended if there's any custom logic which needs to be put in place. Management methods implemented:
- findOne
- findOneById
- find - returns a collection of current model's objects
- create - index a new document
- delete - deletes either a hydrated model / by identifier
- update - updates by state / body & identifier combination Each action will dispatch before and after events through which you can modify data for various cases based on your current flow. The model class also extends the EventEmitter so all methods present there are available.
Main element - initializes the ES connection, bounds each model, injects all dependencies and does some integrity/configuration checks.
A list of internal functions used in order to check/decorate/parse things.
A simple wrapper which uses joi schema validation. It's used for validating data before it gets written in the database accordingly on the provided schema for one model. This step is optional for your project and it only depends on your model configuration when it gets initialized.
Data can be modified for models through event listeners attached on models.
The configuration is quite simple and for the moment it only addresses the ORM and the logger.
Eg.
{
connection: { // elasticsearch package config
host: '10.10.10.1:9200',
requestTimeout: 2000
},
logger: { // passed to the internal logger
level: 10
}
}
- ElasticSearch 6., ElasticSearch 5.
- NodeJS >=m 6.4.0
See the changelog file.
0.1.0 - first version (master)