UNPKG

dynamodb-toolbox

Version:

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

24 lines (23 loc) 964 B
import { TableAction } from '../../../table/index.js'; export class TableDTO extends TableAction { constructor(table) { super(table); this.tableName = this.table.tableName !== undefined ? this.table.getName() : undefined; this.partitionKey = this.table.partitionKey; this.sortKey = this.table.sortKey; this.indexes = this.table.indexes; this.entityAttributeSavedAs = this.table.entityAttributeSavedAs; } toJSON() { return { ...(this.tableName !== undefined ? { tableName: this.tableName } : {}), partitionKey: this.partitionKey, ...(this.sortKey !== undefined ? { sortKey: this.sortKey } : {}), ...(this.indexes !== undefined && Object.entries(this.indexes).length > 0 ? { indexes: this.indexes } : {}), entityAttributeSavedAs: this.entityAttributeSavedAs }; } } TableDTO.actionName = 'dto';