Interface Entity<TItem, TPKSource, TSKSource>

Every object stored via Entity Store must have a corresponding Entity. Each entity must be related to a type (TItem) that must at least define the table key fields, and optionally the other fields of the internal representation of an object

Type Parameters

  • TItem extends TPKSource & TSKSource

  • TPKSource

  • TSKSource

Hierarchy

  • Entity

Properties

convertToDynamoFormat?: EntityFormatter<TItem>

See

EntityFormatter

gsis?: Record<string, GsiGenerators>

A map of GSI ID to generator functions, similar to pk() and sk() Note that the GSI IDs do not have to be the same as the underlying index names, rather they must be the same IDs as those defined in the table configuration (e.g. 'gsi', 'gsi2', if using "standard" configuration.)

parse: EntityParser<TItem>

See

EntityParser

type: string

Must be unique for each Entity used in the store, but can be any string. For tables that store multiple entities the type is stored as a meta attribute on the table

Methods

  • Given a subset of the fields of the entity type, generate the partition key value for the stored version of the object Note that this may be as simple as returning a specific property on the object, but for "single table designs" will often be some kind of encoding of one more fields

    Parameters

    • source: TPKSource

    Returns NativeScalarAttributeValue

  • Given a subset of the fields of the entity type, generate the sort key value for the stored version of the object. This field is required for Entity, since most usages of DynamoDB include a sort key. However if your entity is stored in a table without a sort key then see PKOnlyEntity for a version of Entity that only requires a partition key Note that this may be as simple as returning a specific property on the object, but for "single table designs" will often be some kind of encoding of one more fields

    Parameters

    • source: TSKSource

    Returns NativeScalarAttributeValue

Generated using TypeDoc