dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
20 lines (19 loc) • 590 B
JavaScript
import { SchemaAction } from '../../../schema/index.js';
import { getSchemaDTO } from './getSchemaDTO/index.js';
export class SchemaDTO extends SchemaAction {
constructor(schema) {
super(schema);
this.type = 'item';
this.attributes = Object.fromEntries(Object.entries(this.schema.attributes).map(([attributeName, attribute]) => [
attributeName,
getSchemaDTO(attribute)
]));
}
toJSON() {
return {
type: this.type,
attributes: this.attributes
};
}
}
SchemaDTO.actionName = 'dto';