machinomy
Version:
Micropayments powered by Ethereum
37 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Datastore = require("nedb");
const NedbDatastore_1 = require("./NedbDatastore");
let db = new Map();
class EngineNedb {
constructor(path, inMemoryOnly = false) {
let found = db.get(path);
if (found) {
this.datastore = found;
}
else {
let datastore = new Datastore({ filename: path, autoload: true, inMemoryOnly: inMemoryOnly });
this.datastore = new NedbDatastore_1.default(datastore);
db.set(path, this.datastore);
}
}
isConnected() {
return true;
}
connect() {
return Promise.resolve();
}
close() {
return Promise.resolve();
}
async drop() {
await this.exec(async (client) => {
await client.remove({}, { multi: true });
});
}
async exec(fn) {
return fn(this.datastore);
}
}
exports.default = EngineNedb;
//# sourceMappingURL=EngineNedb.js.map