@flexiblepersistence/backnextapi
Version:
A simple API framework using Flexible Persistence
45 lines • 1.35 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
class DatabaseHandler {
constructor(init) {
this.init = init;
}
getJournaly() {
if (this.init && this.init.journaly)
return this.init.journaly;
throw new Error('DatabaseHandler must have a init and a handler.');
}
getHandler() {
if (this.init && this.init.handler)
return this.init.handler;
throw new Error('DatabaseHandler must have a init and a handler.');
}
getInit() {
if (this.init)
return this.init;
throw new Error('DatabaseHandler must have a init.');
}
getReadHandler() {
const handler = this.getHandler();
if (handler) {
const write = handler.getWrite();
if (write) {
const read = write.getRead();
if (read)
if (read.getReadDB())
return read.getReadDB();
}
}
throw new Error('DatabaseHandler must have a ReadDB.');
}
static getInstance(init) {
if (!this._instance) {
// @ts-ignore
this._instance = new this(init);
}
return this._instance;
}
}
exports.default = DatabaseHandler;
//# sourceMappingURL=databaseHandler.js.map