UNPKG

@whiskeysockets/baileys

Version:
28 lines (27 loc) 687 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObjectRepository = void 0; class ObjectRepository { constructor(entities = {}) { this.entityMap = new Map(Object.entries(entities)); } findById(id) { return this.entityMap.get(id); } findAll() { return Array.from(this.entityMap.values()); } upsertById(id, entity) { return this.entityMap.set(id, { ...entity }); } deleteById(id) { return this.entityMap.delete(id); } count() { return this.entityMap.size; } toJSON() { return this.findAll(); } } exports.ObjectRepository = ObjectRepository;