dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
22 lines (21 loc) • 703 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() {
const { strict } = this.schema.props;
return {
type: this.type,
attributes: this.attributes,
...(strict !== undefined && strict ? { strict } : {})
};
}
}
SchemaDTO.actionName = 'dto';