shiftcode / dynamo-easy

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
https://shiftcode.github.io/dynamo-easy/
MIT License
206 stars 27 forks source link

How CollectionProperty works for CustomType? #304

Closed kdby-io closed 4 years ago

kdby-io commented 4 years ago

The docs says that when I use @CollectionProperty({ itemType: CustomType* }), CustomType must be @Model decorated. If I define like the below, what format is a A record stored as?

@Model()
class A {
  ...
  @CollectionProperty({ itemType: B })
  bs: B[];
}

@Model()
class B {
  @PartitionKey()
  pk: string;

  @SortKey()
  sk: string;
}
simonmumenthaler commented 4 years ago

Your PartitionKey/SortKey decorators in class B are useless in this example since it is nested in A.

When storing an A item the bs property will be mapped to a (L)ist attribute containing (M)ap attributes.

kdby-io commented 4 years ago

@simonmumenthaler you mean that B is not related with any table even if it is @model decorated.

Thank you :)