UNPKG

@naturalcycles/db-lib

Version:

Lowest Common Denominator API to supported Databases

26 lines (25 loc) 683 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InMemoryPersistencePlugin = void 0; const js_lib_1 = require("@naturalcycles/js-lib"); /** * Mostly useful for testing. */ class InMemoryPersistencePlugin { constructor() { this.data = {}; } async ping() { } async getTables() { return Object.keys(this.data); } async loadFile(table) { return Object.values(this.data[table] || {}); } async saveFiles(ops) { ops.forEach(op => { this.data[op.table] = (0, js_lib_1._by)(op.rows, r => r.id); }); } } exports.InMemoryPersistencePlugin = InMemoryPersistencePlugin;