Skip to content

Can I use an entities sortKey as number #183

Closed Locked Answered by whimzyLive
obiwabrakenobi asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @obiwabrakenobi ,

Yes, it is supported via aliases.
if your entity contains an attribute named as timestamp, then instead of defining a template for sortKey as {{timestamp}}, you can directly reference that attribute, like

@Entity<Event>({
  name: 'Event',
  ...,
  sortKey: {
    alias: 'timestamp'   // <- this tells TypeDORM to auto infer "type" and "value" for partition key from "timestamp" attribute.
    }
})
class Event {
@Attribute()
timestamp: number 
}

Let me know if this helps.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@obiwabrakenobi
Comment options

@whimzyLive
Comment options

@obiwabrakenobi
Comment options

@whimzyLive
Comment options

@whimzyLive
Comment options

Answer selected by whimzyLive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants