UNPKG

@mikro-orm/core

Version:

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.

34 lines (33 loc) 712 B
/** Cache adapter backed by pre-generated static data, typically produced by the CLI cache:generate command. */ export class GeneratedCacheAdapter { #data; constructor(options) { this.#data = new Map(Object.entries(options.data)); } /** * @inheritDoc */ get(name) { const key = name.replace(/\.[jt]s$/, ''); const data = this.#data.get(key); return data; } /** * @inheritDoc */ set(name, data, origin) { this.#data.set(name, { data }); } /** * @inheritDoc */ remove(name) { this.#data.delete(name); } /** * @inheritDoc */ clear() { this.#data.clear(); } }