UNPKG

@naturalcycles/db-lib

Version:

Lowest Common Denominator API to supported Databases

20 lines (19 loc) 471 B
import { _by } from '@naturalcycles/js-lib/array/array.util.js'; /** * Mostly useful for testing. */ export class InMemoryPersistencePlugin { 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] = _by(op.rows, r => r.id); }); } }