Skip to content

Support adding default auto generated attributes on all entities #87

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

You must be logged in to vote

@owain68
Hi, you can already achieve this today by leveraging entity inheritance.

// Create a base entity with all the attributes you normally have
abstract class BaseEntity {
  @AutoGenerateAttribute({
    strategy: AUTO_GENERATE_ATTRIBUTE_STRATEGY.ISO_DATE
  })
  createdAt: string
} 

// Create other entities from the base entity
class User extends BaseEntity {
  @AutoGenerateAttribute({
    strategy: AUTO_GENERATE_ATTRIBUTE_STRATEGY.UUID4
  })
  id: string
} 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by owain68
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