dynamode icon indicating copy to clipboard operation
dynamode copied to clipboard

Add a decorator to set custom names for entities

Open blazejkustra opened this issue 6 months ago • 0 comments

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: image

blazejkustra avatar Aug 03 '24 10:08 blazejkustra