Open jonterry-sans opened 4 years ago
Both hashKey
and rangeKey
are just thin wrappers around @attribute
, so in the example you provide, I believe the @hashKey
decorator will override what was specified in the @rangeKey
decorator. Targeting the same property with two separate @attribute
decorators like that should probably throw to prevent ambiguous situations like this.
The schema used by the mapper is keyed by property name, so to get the schema you want to work, I believe you would need to use one property and one getter that proxies to that property, e.g.,
@hashKey({
attributeName: "partitionKey",
defaultProvider: (): string => `record#${uuid.v4}`
})
id!: string;
@rangeKey()
get sortKey(): string {
return this.id;
}
Looking for suggestions on how best to accomplish defining a model property that is both the partion/hash key as well as the sort/range key.
Due to a table design i need to duplicate an ID across both the Partition and Sort key on my table. Ideally this would leverage a default provider, and only shown as a single property on the model. Does anyone have any suggestions or thoughts regarding an implementation that would accomplish this. Is it possible to write a custom datamapper annotation to support this design?