dynamode
dynamode copied to clipboard
Add a decorator to set custom names for entities
Fixes https://github.com/blazejkustra/dynamode/issues/32. Now it is possible to overwrite the name of the class with a decorator.
import Table, { tableManager, TableProps } from "./table";
import attribute, { entity } from "dynamode/decorators";
export interface UserProps {
pk: string;
}
@entity.customName("USER_ENTITY")
export class User extends Table {
@attribute.partitionKey.string({ prefix: "USER" })
pk!: string;
constructor(props: UserProps) {
super(props);
}
}
export const UserManager = tableManager.entityManager(User);
The outcome is that you get entity names even with minification: