You can write your own Thorin stores by implementing thorin.Interface.Store
and calling thorin.addStore()
Since Thorin stores are designed as an abstraction layer between your application and your databases, a set of minimal
functionality is required to be implemented. The store interface also extends the native EventEmitter
class,
transforming your store into an event emitter by default.
The configuration of a store should be placed under the store
key of the application's root configuration object
and under the store's name
property. A small example is available below.
'use strict';
// config/app.js file
module.exports = {
"store.redisDb": { // the "redisDb" key is the store's name property
port: 12345
}
};
super()
constructor from your class, so that it can initiate any
other dependencies of the store class.
name
property.'use strict';
class ThorinRedisStore extends thorin.Interface.Store {
static publicName() { return 'Redis' }
// Constructor
constructor(){
super(); // this will set the name of the store.
this.type = "redis";
this.connection = null;
}
// Called when the store's configuration is available.
init(config) {
this.config = config;
}
// Called when the application is booting.
// We should connect to the redis store, handle reconnect, etc.
run(done) {
// do async stuff
done();
}
// Terminate the connection, flush anything and callback.
stop(done) {
// disconnect from the server.
done();
}
}
thorin.addStore(ThorinRedisStore, 'redisDb');
You can always create a new issue on GitHub or contact one of the core founders by chat.