cogsbox-shape
Version:
A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for r
23 lines (22 loc) • 588 B
JavaScript
export class RemapStore {
map = new Map();
set(table, tempId, realId) {
let tableMap = this.map.get(table);
if (!tableMap) {
tableMap = new Map();
this.map.set(table, tableMap);
}
tableMap.set(tempId, realId);
}
toObject() {
const obj = {};
for (const [table, tableMap] of this.map) {
const entries = {};
for (const [temp, real] of tableMap) {
entries[String(temp)] = real;
}
obj[table] = entries;
}
return obj;
}
}