UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

21 lines (20 loc) 580 B
import { Registry } from '../table/actions/registry/registry.js'; import { Table } from '../table/index.js'; export class Database { constructor(tables, { meta = {} } = {}) { this.tables = register(tables); this.meta = meta; } build(Action) { return new Action(this); } } export class DatabaseAction { constructor(database) { this.database = database; } } const register = (tables) => Object.fromEntries(Object.entries(tables).map(([key, table]) => [ key, table instanceof Table ? table.build(Registry) : table ]));