Documentation ¶
Overview ¶
Package versionary provides an opinionated way of managing versioned entities in a NoSQL database.
Index ¶
- Variables
- func Batch[T any](items []T, batchSize int) [][]T
- func Contains[T comparable](s []T, value T) bool
- func ContainsFilter(contains string, anyMatch bool) (func(tv TextValue) bool, error)
- func Filter[T any](s []T, f func(T) bool) []T
- func FromCompressedJSON[T any](j []byte) (T, error)
- func FromJSON[T any](j []byte) (T, error)
- func IsValidDate(date string) bool
- func Map[T1, T2 any](s []T1, f func(T1) T2) []T2
- func NumValuesMap(values []NumValue) map[string]float64
- func Reduce[T1, T2 any](s []T1, initializer T2, f func(T2, T1) T2) T2
- func TextValuesMap(values []TextValue) map[string]string
- func ToCompressedJSON[T any](entity T) ([]byte, error)
- func ToJSON[T any](t T) ([]byte, error)
- func UncompressJSON(j []byte) ([]byte, error)
- type MemTable
- func (table MemTable[T]) CountPartKeyValues(ctx context.Context, row TableRow[T]) (int64, error)
- func (table MemTable[T]) CountSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) (int64, error)
- func (table MemTable[T]) DeleteEntity(ctx context.Context, entity T) error
- func (table MemTable[T]) DeleteEntityVersionWithID(ctx context.Context, entityID, versionID string) (T, error)
- func (table MemTable[T]) DeleteEntityWithID(ctx context.Context, entityID string) (T, error)
- func (table MemTable[T]) DeleteItem(ctx context.Context, rowPartKeyValue string, sortKeyValue string) error
- func (table MemTable[T]) DeleteRow(ctx context.Context, row TableRow[T], partKeyValue string) error
- func (table MemTable[T]) EntityExists(ctx context.Context, entityID string) bool
- func (table MemTable[T]) EntityID(entity T) string
- func (table MemTable[T]) EntityReferenceID(entity T) string
- func (table MemTable[T]) EntityVersionExists(ctx context.Context, entityID string, versionID string) bool
- func (table MemTable[T]) EntityVersionID(entity T) string
- func (table MemTable[T]) FilterEntityLabels(ctx context.Context, f func(TextValue) bool) ([]TextValue, error)
- func (table MemTable[T]) FilterPartKeyLabels(ctx context.Context, row TableRow[T], f func(TextValue) bool) ([]TextValue, error)
- func (table MemTable[T]) FilterTextValues(ctx context.Context, row TableRow[T], partKeyValue string, ...) ([]TextValue, error)
- func (table MemTable[T]) GetEntityRow() TableRow[T]
- func (table MemTable[T]) GetEntityType() string
- func (table MemTable[T]) GetRow(rowName string) (TableRow[T], bool)
- func (table MemTable[T]) GetTableName() string
- func (table MemTable[T]) IsValid() bool
- func (table MemTable[T]) ReadAllEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string) ([]T, error)
- func (table MemTable[T]) ReadAllEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string) ([]byte, error)
- func (table MemTable[T]) ReadAllEntityIDs(ctx context.Context) ([]string, error)
- func (table MemTable[T]) ReadAllEntityLabels(ctx context.Context, sortByValue bool) ([]TextValue, error)
- func (table MemTable[T]) ReadAllEntityVersionIDs(ctx context.Context, entityID string) ([]string, error)
- func (table MemTable[T]) ReadAllEntityVersions(ctx context.Context, entityID string) ([]T, error)
- func (table MemTable[T]) ReadAllEntityVersionsAsJSON(ctx context.Context, entityID string) ([]byte, error)
- func (table MemTable[T]) ReadAllNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]NumValue, error)
- func (table MemTable[T]) ReadAllPartKeyLabels(ctx context.Context, row TableRow[T], sortByValue bool) ([]TextValue, error)
- func (table MemTable[T]) ReadAllPartKeyValues(ctx context.Context, row TableRow[T]) ([]string, error)
- func (table MemTable[T]) ReadAllRecords(ctx context.Context, row TableRow[T], partKeyValue string) ([]Record, error)
- func (table MemTable[T]) ReadAllSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) ([]string, error)
- func (table MemTable[T]) ReadAllTextValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]TextValue, error)
- func (table MemTable[T]) ReadCurrentEntityVersionID(ctx context.Context, entityID string) (string, error)
- func (table MemTable[T]) ReadEntities(ctx context.Context, entityIDs []string) []T
- func (table MemTable[T]) ReadEntitiesAsJSON(ctx context.Context, entityIDs []string) []byte
- func (table MemTable[T]) ReadEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]T, error)
- func (table MemTable[T]) ReadEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]byte, error)
- func (table MemTable[T]) ReadEntity(ctx context.Context, entityID string) (T, error)
- func (table MemTable[T]) ReadEntityAsCompressedJSON(ctx context.Context, entityID string) ([]byte, error)
- func (table MemTable[T]) ReadEntityAsJSON(ctx context.Context, entityID string) ([]byte, error)
- func (table MemTable[T]) ReadEntityFromRow(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (T, error)
- func (table MemTable[T]) ReadEntityFromRowAsCompressedJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
- func (table MemTable[T]) ReadEntityFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
- func (table MemTable[T]) ReadEntityIDRange(ctx context.Context, from string, to string, reverse bool) ([]string, error)
- func (table MemTable[T]) ReadEntityIDs(ctx context.Context, reverse bool, limit int, offset string) ([]string, error)
- func (table MemTable[T]) ReadEntityLabel(ctx context.Context, entityID string) (TextValue, error)
- func (table MemTable[T]) ReadEntityLabelRange(ctx context.Context, from, to string, reverse bool) ([]TextValue, error)
- func (table MemTable[T]) ReadEntityLabels(ctx context.Context, reverse bool, limit int, offset string) ([]TextValue, error)
- func (table MemTable[T]) ReadEntityRangeFromRow(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]T, error)
- func (table MemTable[T]) ReadEntityRangeFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]byte, error)
- func (table MemTable[T]) ReadEntityVersion(ctx context.Context, entityID string, versionID string) (T, error)
- func (table MemTable[T]) ReadEntityVersionAsJSON(ctx context.Context, entityID string, versionID string) ([]byte, error)
- func (table MemTable[T]) ReadEntityVersionIDs(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]string, error)
- func (table MemTable[T]) ReadEntityVersions(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]T, error)
- func (table MemTable[T]) ReadEntityVersionsAsJSON(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]byte, error)
- func (table MemTable[T]) ReadFirstSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
- func (table MemTable[T]) ReadLastSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
- func (table MemTable[T]) ReadNumericValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (NumValue, error)
- func (table MemTable[T]) ReadNumericValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]NumValue, error)
- func (table MemTable[T]) ReadNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]NumValue, error)
- func (table MemTable[T]) ReadPartKeyLabel(ctx context.Context, row TableRow[T], partKeyValue string) (TextValue, error)
- func (table MemTable[T]) ReadPartKeyLabelRange(ctx context.Context, row TableRow[T], from, to string, reverse bool) ([]TextValue, error)
- func (table MemTable[T]) ReadPartKeyLabels(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]TextValue, error)
- func (table MemTable[T]) ReadPartKeyValueRange(ctx context.Context, row TableRow[T], from string, to string, reverse bool) ([]string, error)
- func (table MemTable[T]) ReadPartKeyValues(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]string, error)
- func (table MemTable[T]) ReadRecord(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (Record, error)
- func (table MemTable[T]) ReadRecordRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]Record, error)
- func (table MemTable[T]) ReadRecords(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]Record, error)
- func (table MemTable[T]) ReadSortKeyValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from string, ...) ([]string, error)
- func (table MemTable[T]) ReadSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]string, error)
- func (table MemTable[T]) ReadTextValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (TextValue, error)
- func (table MemTable[T]) ReadTextValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]TextValue, error)
- func (table MemTable[T]) ReadTextValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]TextValue, error)
- func (table MemTable[T]) TableExists() bool
- func (table MemTable[T]) UpdateEntity(ctx context.Context, entity T) error
- func (table MemTable[T]) UpdateEntityVersion(ctx context.Context, oldVersion T, newVersion T) error
- func (table MemTable[T]) WriteEntity(ctx context.Context, entity T) error
- type NumValue
- type Record
- type RecordSet
- func (rs *RecordSet) CountSortKeys(partKey string) int64
- func (rs *RecordSet) DeleteRecord(r Record)
- func (rs *RecordSet) DeleteRecordForKeys(partKey string, sortKey string)
- func (rs *RecordSet) DeleteRecords(records []Record)
- func (rs *RecordSet) DeleteRecordsForKey(partKey string)
- func (rs *RecordSet) GetRecord(partKey string, sortKey string) (Record, bool)
- func (rs *RecordSet) GetRecords(partKey string, sortKeys []string) []Record
- func (rs *RecordSet) GetSortKeys(partKey string) []string
- func (rs *RecordSet) RecordExists(partKey string, sortKey string) bool
- func (rs *RecordSet) RecordsExist(partKey string) bool
- func (rs *RecordSet) SetRecord(r Record)
- func (rs *RecordSet) SetRecords(records []Record)
- type Table
- func (table Table[T]) CountPartKeyValues(ctx context.Context, row TableRow[T]) (int64, error)
- func (table Table[T]) CountSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) (int64, error)
- func (table Table[T]) CreateTable(ctx context.Context) error
- func (table Table[T]) DeleteEntity(ctx context.Context, entity T) error
- func (table Table[T]) DeleteEntityVersionWithID(ctx context.Context, entityID, versionID string) (T, error)
- func (table Table[T]) DeleteEntityWithID(ctx context.Context, entityID string) (T, error)
- func (table Table[T]) DeleteItem(ctx context.Context, rowPartKeyValue string, sortKeyValue string) error
- func (table Table[T]) DeleteRow(ctx context.Context, row TableRow[T], partKeyValue string) error
- func (table Table[T]) DeleteTable(ctx context.Context) error
- func (table Table[T]) EntityExists(ctx context.Context, entityID string) bool
- func (table Table[T]) EntityID(entity T) string
- func (table Table[T]) EntityReferenceID(entity T) string
- func (table Table[T]) EntityVersionExists(ctx context.Context, entityID string, versionID string) bool
- func (table Table[T]) EntityVersionID(entity T) string
- func (table Table[T]) FilterEntityLabels(ctx context.Context, f func(TextValue) bool) ([]TextValue, error)
- func (table Table[T]) FilterPartKeyLabels(ctx context.Context, row TableRow[T], f func(TextValue) bool) ([]TextValue, error)
- func (table Table[T]) FilterTextValues(ctx context.Context, row TableRow[T], partKeyValue string, ...) ([]TextValue, error)
- func (table Table[T]) GetEntityRow() TableRow[T]
- func (table Table[T]) GetEntityType() string
- func (table Table[T]) GetRow(rowName string) (TableRow[T], bool)
- func (table Table[T]) GetTableDescription(ctx context.Context) (*types.TableDescription, error)
- func (table Table[T]) GetTableName() string
- func (table Table[T]) IsValid() bool
- func (table Table[T]) ReadAllEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string) ([]T, error)
- func (table Table[T]) ReadAllEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string) ([]byte, error)
- func (table Table[T]) ReadAllEntityIDs(ctx context.Context) ([]string, error)
- func (table Table[T]) ReadAllEntityLabels(ctx context.Context, sortByValue bool) ([]TextValue, error)
- func (table Table[T]) ReadAllEntityVersionIDs(ctx context.Context, entityID string) ([]string, error)
- func (table Table[T]) ReadAllEntityVersions(ctx context.Context, entityID string) ([]T, error)
- func (table Table[T]) ReadAllEntityVersionsAsJSON(ctx context.Context, entityID string) ([]byte, error)
- func (table Table[T]) ReadAllNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]NumValue, error)
- func (table Table[T]) ReadAllPartKeyLabels(ctx context.Context, row TableRow[T], sortByValue bool) ([]TextValue, error)
- func (table Table[T]) ReadAllPartKeyValues(ctx context.Context, row TableRow[T]) ([]string, error)
- func (table Table[T]) ReadAllRecords(ctx context.Context, row TableRow[T], partKeyValue string) ([]Record, error)
- func (table Table[T]) ReadAllSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) ([]string, error)
- func (table Table[T]) ReadAllTextValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]TextValue, error)
- func (table Table[T]) ReadCurrentEntityVersionID(ctx context.Context, entityID string) (string, error)
- func (table Table[T]) ReadEntities(ctx context.Context, entityIDs []string) []T
- func (table Table[T]) ReadEntitiesAsJSON(ctx context.Context, entityIDs []string) []byte
- func (table Table[T]) ReadEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]T, error)
- func (table Table[T]) ReadEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]byte, error)
- func (table Table[T]) ReadEntity(ctx context.Context, entityID string) (T, error)
- func (table Table[T]) ReadEntityAsCompressedJSON(ctx context.Context, entityID string) ([]byte, error)
- func (table Table[T]) ReadEntityAsJSON(ctx context.Context, entityID string) ([]byte, error)
- func (table Table[T]) ReadEntityFromRow(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (T, error)
- func (table Table[T]) ReadEntityFromRowAsCompressedJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
- func (table Table[T]) ReadEntityFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
- func (table Table[T]) ReadEntityIDRange(ctx context.Context, from string, to string, reverse bool) ([]string, error)
- func (table Table[T]) ReadEntityIDs(ctx context.Context, reverse bool, limit int, offset string) ([]string, error)
- func (table Table[T]) ReadEntityLabel(ctx context.Context, entityID string) (TextValue, error)
- func (table Table[T]) ReadEntityLabelRange(ctx context.Context, from, to string, reverse bool) ([]TextValue, error)
- func (table Table[T]) ReadEntityLabels(ctx context.Context, reverse bool, limit int, offset string) ([]TextValue, error)
- func (table Table[T]) ReadEntityRangeFromRow(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]T, error)
- func (table Table[T]) ReadEntityRangeFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]byte, error)
- func (table Table[T]) ReadEntityVersion(ctx context.Context, entityID string, versionID string) (T, error)
- func (table Table[T]) ReadEntityVersionAsJSON(ctx context.Context, entityID string, versionID string) ([]byte, error)
- func (table Table[T]) ReadEntityVersionIDs(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]string, error)
- func (table Table[T]) ReadEntityVersions(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]T, error)
- func (table Table[T]) ReadEntityVersionsAsJSON(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]byte, error)
- func (table Table[T]) ReadFirstSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
- func (table Table[T]) ReadLastSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
- func (table Table[T]) ReadNumericValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (NumValue, error)
- func (table Table[T]) ReadNumericValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]NumValue, error)
- func (table Table[T]) ReadNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]NumValue, error)
- func (table Table[T]) ReadPartKeyLabel(ctx context.Context, row TableRow[T], partKeyValue string) (TextValue, error)
- func (table Table[T]) ReadPartKeyLabelRange(ctx context.Context, row TableRow[T], from, to string, reverse bool) ([]TextValue, error)
- func (table Table[T]) ReadPartKeyLabels(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]TextValue, error)
- func (table Table[T]) ReadPartKeyValueRange(ctx context.Context, row TableRow[T], from string, to string, reverse bool) ([]string, error)
- func (table Table[T]) ReadPartKeyValues(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]string, error)
- func (table Table[T]) ReadRecord(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (Record, error)
- func (table Table[T]) ReadRecordRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]Record, error)
- func (table Table[T]) ReadRecords(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]Record, error)
- func (table Table[T]) ReadSortKeyValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from string, ...) ([]string, error)
- func (table Table[T]) ReadSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]string, error)
- func (table Table[T]) ReadTextValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (TextValue, error)
- func (table Table[T]) ReadTextValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, ...) ([]TextValue, error)
- func (table Table[T]) ReadTextValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, ...) ([]TextValue, error)
- func (table Table[T]) TableExists(ctx context.Context) bool
- func (table Table[T]) UpdateEntity(ctx context.Context, entity T) error
- func (table Table[T]) UpdateEntityVersion(ctx context.Context, oldVersion T, newVersion T) error
- func (table Table[T]) UpdateTTL(ctx context.Context) error
- func (table Table[T]) WriteEntity(ctx context.Context, entity T) error
- type TableReadWriter
- type TableReader
- type TableRow
- type TableWriter
- type TextValue
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyFilter = errors.New("empty filter")
ErrEmptyFilter is returned when the filter string is empty.
var ErrNotFound = errors.New("versionary: not found")
ErrNotFound is returned when a specified thing is not found
Functions ¶
func Batch ¶ added in v1.2.0
Batch divides the provided slice of things into batches of the specified maximum size.
func Contains ¶
func Contains[T comparable](s []T, value T) bool
Contains returns true if the slice contains the provided value.
func ContainsFilter ¶ added in v1.4.0
ContainsFilter returns a function that can be used to filter TextValues. The case-insensitive contains query is split into words, and the words are compared with the value in the TextValue. If anyMatch is true, then a TextValue is included in the results if any of the words are found (OR filter). If anyMatch is false, then the TextValue must contain all the words in the query string (AND filter).
func Filter ¶
Filter filters values from a slice using a filter function. It returns a new slice with only the elements of s that satisfy the predicate.
func FromCompressedJSON ¶ added in v1.1.0
FromCompressedJSON deserializes the provided gzip-compressed JSON byte slice into an entity.
func IsValidDate ¶ added in v1.4.0
IsValidDate returns true if the supplied string is a valid date in the format YYYY-MM-DD. Note that this function does not validate the actual number of days in a given month. For example, it does not indicate that February 31 is invalid. It only validates the format, including the maximum value for each field.
func Map ¶
func Map[T1, T2 any](s []T1, f func(T1) T2) []T2
Map turns a slice of T1 into a slice of T2 using a mapping function.
func NumValuesMap ¶ added in v1.4.0
NumValuesMap converts a slice of NumValues into a key/value map.
func Reduce ¶
func Reduce[T1, T2 any](s []T1, initializer T2, f func(T2, T1) T2) T2
Reduce reduces a slice of T1 to a single value using a reduction function.
func TextValuesMap ¶ added in v1.4.0
TextValuesMap converts a slice of TextValues into a key/value map.
func ToCompressedJSON ¶ added in v1.1.0
ToCompressedJSON serializes the provided entity as a gzip-compressed JSON byte slice.
func UncompressJSON ¶ added in v1.1.0
UncompressJSON converts the provided gzip-compressed JSON byte slice into uncompressed bytes.
Types ¶
type MemTable ¶
type MemTable[T any] struct { Records *RecordSet EntityType string TableName string TTL bool EntityRow TableRow[T] IndexRows map[string]TableRow[T] }
MemTable represents a single in-memory table that stores all the "wide rows" for a given entity. Denormalized entity data are stored in a single table, reusing the attribute names indicated in the TableRow definition. The EntityRow is special; it contains the revision history for the entity, whereas the IndexRows contain only values from the latest version of the entity. MemTable implements the TableWriter and TableReader interfaces and is intended to be used for testing purposes only.
func NewMemTable ¶
NewMemTable creates a new MemTable from a DynamoDB table definition.
func (MemTable[T]) CountPartKeyValues ¶ added in v1.3.0
CountPartKeyValues counts the total number of partition key values for the specified row.
func (MemTable[T]) CountSortKeyValues ¶ added in v1.3.0
func (table MemTable[T]) CountSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) (int64, error)
CountSortKeyValues counts the total number of sort key values for the specified row and partition key.
func (MemTable[T]) DeleteEntity ¶
DeleteEntity deletes the provided entity from the table (including all versions).
func (MemTable[T]) DeleteEntityVersionWithID ¶ added in v1.3.0
func (table MemTable[T]) DeleteEntityVersionWithID(ctx context.Context, entityID, versionID string) (T, error)
DeleteEntityVersionWithID deletes the specified version of the entity from the table.
func (MemTable[T]) DeleteEntityWithID ¶
DeleteEntityWithID deletes the specified entity from the table (including all versions).
func (MemTable[T]) DeleteItem ¶
func (table MemTable[T]) DeleteItem(ctx context.Context, rowPartKeyValue string, sortKeyValue string) error
DeleteItem deletes the item with the specified row partition key and sort key. Note that this method will seldom be used. It is primarily for cleaning up obsolete items.
func (MemTable[T]) EntityExists ¶
EntityExists checks if an entity exists in the table.
func (MemTable[T]) EntityID ¶ added in v1.2.0
EntityID returns the unique entity ID for the provided entity.
func (MemTable[T]) EntityReferenceID ¶ added in v1.2.0
EntityReferenceID returns a unique Reference ID (EntityType-ID-VersionID) for the provided entity.
func (MemTable[T]) EntityVersionExists ¶
func (table MemTable[T]) EntityVersionExists(ctx context.Context, entityID string, versionID string) bool
EntityVersionExists checks if an entity version exists in the table.
func (MemTable[T]) EntityVersionID ¶ added in v1.2.0
EntityVersionID returns the unique entity version ID for the provided entity.
func (MemTable[T]) FilterEntityLabels ¶ added in v1.3.0
func (table MemTable[T]) FilterEntityLabels(ctx context.Context, f func(TextValue) bool) ([]TextValue, error)
FilterEntityLabels returns all entity labels that match the specified filter. The resulting text values are sorted by value.
func (MemTable[T]) FilterPartKeyLabels ¶ added in v1.3.0
func (table MemTable[T]) FilterPartKeyLabels(ctx context.Context, row TableRow[T], f func(TextValue) bool) ([]TextValue, error)
FilterPartKeyLabels returns all partition key labels from the specified row that match the specified filter. The resulting text values are sorted by value.
func (MemTable[T]) FilterTextValues ¶ added in v1.3.0
func (table MemTable[T]) FilterTextValues(ctx context.Context, row TableRow[T], partKeyValue string, f func(TextValue) bool) ([]TextValue, error)
FilterTextValues returns all text values from the specified row that match the specified filter. The resulting text values are sorted by value.
func (MemTable[T]) GetEntityRow ¶
GetEntityRow returns the entity row definition. This row contains the revision history for the entity.
func (MemTable[T]) GetEntityType ¶ added in v1.3.0
GetEntityType returns the name of the entity type for the MemTable.
func (MemTable[T]) GetTableName ¶ added in v1.3.0
GetTableName returns the name of the table.
func (MemTable[T]) ReadAllEntitiesFromRow ¶
func (table MemTable[T]) ReadAllEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string) ([]T, error)
ReadAllEntitiesFromRow reads all entities from the specified row. Note: this could be a lot of data! It should only be used for small collections.
func (MemTable[T]) ReadAllEntitiesFromRowAsJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadAllEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string) ([]byte, error)
ReadAllEntitiesFromRowAsJSON reads all entities from the specified row as a JSON byte slice. Note: this could be a lot of data! It should only be used for small collections.
func (MemTable[T]) ReadAllEntityIDs ¶
ReadAllEntityIDs reads all entity IDs from the EntityRow. Note that this can return a very large number of IDs!
func (MemTable[T]) ReadAllEntityLabels ¶ added in v1.3.0
func (table MemTable[T]) ReadAllEntityLabels(ctx context.Context, sortByValue bool) ([]TextValue, error)
ReadAllEntityLabels reads all entity labels. Note: this can return a very large number of values! Use with caution.
func (MemTable[T]) ReadAllEntityVersionIDs ¶
func (table MemTable[T]) ReadAllEntityVersionIDs(ctx context.Context, entityID string) ([]string, error)
ReadAllEntityVersionIDs reads all entity version IDs for the specified entity. Note that this can return a very large number of IDs!
func (MemTable[T]) ReadAllEntityVersions ¶
ReadAllEntityVersions reads all versions of the specified entity. Note: this can return a very large number of versions! Use with caution.
func (MemTable[T]) ReadAllEntityVersionsAsJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadAllEntityVersionsAsJSON(ctx context.Context, entityID string) ([]byte, error)
ReadAllEntityVersionsAsJSON reads all versions of the specified entity as a JSON byte slice. Note: this can return a very large number of versions! Use with caution.
func (MemTable[T]) ReadAllNumericValues ¶
func (table MemTable[T]) ReadAllNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]NumValue, error)
ReadAllNumericValues reads all numeric values from the specified row. Note: this can return a very large number of values! Use with caution.
func (MemTable[T]) ReadAllPartKeyLabels ¶ added in v1.3.0
func (table MemTable[T]) ReadAllPartKeyLabels(ctx context.Context, row TableRow[T], sortByValue bool) ([]TextValue, error)
ReadAllPartKeyLabels reads all partition key labels from the specified row. Note: this can return a very large number of values! Use with caution.
func (MemTable[T]) ReadAllPartKeyValues ¶
func (table MemTable[T]) ReadAllPartKeyValues(ctx context.Context, row TableRow[T]) ([]string, error)
ReadAllPartKeyValues reads all the values of the partition keys used for the specified row. Note that for some rows, this may be a very large number of values.
func (MemTable[T]) ReadAllRecords ¶ added in v1.2.0
func (table MemTable[T]) ReadAllRecords(ctx context.Context, row TableRow[T], partKeyValue string) ([]Record, error)
ReadAllRecords reads all Records from the specified row. Note: this can return a very large number of values! Use with caution.
func (MemTable[T]) ReadAllSortKeyValues ¶
func (table MemTable[T]) ReadAllSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) ([]string, error)
ReadAllSortKeyValues reads all the sort key values for the specified row and partition key value. Note that for some rows, this may be a very large number of values.
func (MemTable[T]) ReadAllTextValues ¶
func (table MemTable[T]) ReadAllTextValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]TextValue, error)
ReadAllTextValues reads all text values from the specified row. Note: this can return a very large number of values! Use with caution.
func (MemTable[T]) ReadCurrentEntityVersionID ¶
func (table MemTable[T]) ReadCurrentEntityVersionID(ctx context.Context, entityID string) (string, error)
ReadCurrentEntityVersionID reads the current entity version ID for the specified entity.
func (MemTable[T]) ReadEntities ¶
ReadEntities reads the current versions of the specified entities from the EntityRow. If an entity does not exist, it will be omitted from the results.
func (MemTable[T]) ReadEntitiesAsJSON ¶ added in v1.1.0
ReadEntitiesAsJSON reads the current versions of the specified entities from the EntityRow as a JSON byte slice. If an entity does not exist, it will be omitted from the results.
func (MemTable[T]) ReadEntitiesFromRow ¶
func (table MemTable[T]) ReadEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]T, error)
ReadEntitiesFromRow reads paginated entities from the specified row.
func (MemTable[T]) ReadEntitiesFromRowAsJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]byte, error)
ReadEntitiesFromRowAsJSON reads paginated entities from the specified row, returning a JSON byte slice.
func (MemTable[T]) ReadEntity ¶
ReadEntity reads the current version of the specified entity.
func (MemTable[T]) ReadEntityAsCompressedJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadEntityAsCompressedJSON(ctx context.Context, entityID string) ([]byte, error)
ReadEntityAsCompressedJSON reads the current version of the specified entity, returning a compressed JSON byte slice.
func (MemTable[T]) ReadEntityAsJSON ¶ added in v1.1.0
ReadEntityAsJSON reads the current version of the specified entity as a JSON byte slice.
func (MemTable[T]) ReadEntityFromRow ¶
func (table MemTable[T]) ReadEntityFromRow(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (T, error)
ReadEntityFromRow reads the specified entity from the specified row.
func (MemTable[T]) ReadEntityFromRowAsCompressedJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadEntityFromRowAsCompressedJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
ReadEntityFromRowAsCompressedJSON reads the specified entity from the specified row as compressed JSON bytes.
func (MemTable[T]) ReadEntityFromRowAsJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadEntityFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
ReadEntityFromRowAsJSON reads the specified entity from the specified row as JSON bytes.
func (MemTable[T]) ReadEntityIDRange ¶ added in v1.4.0
func (table MemTable[T]) ReadEntityIDRange(ctx context.Context, from string, to string, reverse bool) ([]string, error)
ReadEntityIDRange reads a range of entity IDs from the EntityRow, where the entity IDs range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadEntityIDs ¶
func (table MemTable[T]) ReadEntityIDs(ctx context.Context, reverse bool, limit int, offset string) ([]string, error)
ReadEntityIDs reads paginated entity IDs from the EntityRow.
func (MemTable[T]) ReadEntityLabel ¶ added in v1.3.0
ReadEntityLabel reads the label for the specified entity.
func (MemTable[T]) ReadEntityLabelRange ¶ added in v1.4.0
func (table MemTable[T]) ReadEntityLabelRange(ctx context.Context, from, to string, reverse bool) ([]TextValue, error)
ReadEntityLabelRange reads a range of entity labels, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadEntityLabels ¶ added in v1.3.0
func (table MemTable[T]) ReadEntityLabels(ctx context.Context, reverse bool, limit int, offset string) ([]TextValue, error)
ReadEntityLabels reads paginated entity labels.
func (MemTable[T]) ReadEntityRangeFromRow ¶ added in v1.4.0
func (table MemTable[T]) ReadEntityRangeFromRow(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]T, error)
ReadEntityRangeFromRow reads a range of entities from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadEntityRangeFromRowAsJSON ¶ added in v1.4.0
func (table MemTable[T]) ReadEntityRangeFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]byte, error)
ReadEntityRangeFromRowAsJSON reads a range of entities from the specified row as JSON, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadEntityVersion ¶
func (table MemTable[T]) ReadEntityVersion(ctx context.Context, entityID string, versionID string) (T, error)
ReadEntityVersion reads the specified version of the specified entity.
func (MemTable[T]) ReadEntityVersionAsJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadEntityVersionAsJSON(ctx context.Context, entityID string, versionID string) ([]byte, error)
ReadEntityVersionAsJSON reads the specified version of the specified entity as a JSON byte slice.
func (MemTable[T]) ReadEntityVersionIDs ¶
func (table MemTable[T]) ReadEntityVersionIDs(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]string, error)
ReadEntityVersionIDs reads paginated entity version IDs for the specified entity.
func (MemTable[T]) ReadEntityVersions ¶
func (table MemTable[T]) ReadEntityVersions(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]T, error)
ReadEntityVersions reads paginated versions of the specified entity.
func (MemTable[T]) ReadEntityVersionsAsJSON ¶ added in v1.1.0
func (table MemTable[T]) ReadEntityVersionsAsJSON(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]byte, error)
ReadEntityVersionsAsJSON reads paginated versions of the specified entity as a JSON byte slice.
func (MemTable[T]) ReadFirstSortKeyValue ¶ added in v1.2.0
func (table MemTable[T]) ReadFirstSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
ReadFirstSortKeyValue reads the first sort key value for the specified row and partition key value. This method is typically used for looking up an ID corresponding to a foreign key.
func (MemTable[T]) ReadLastSortKeyValue ¶ added in v1.2.0
func (table MemTable[T]) ReadLastSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
ReadLastSortKeyValue reads the last sort key value for the specified row and partition key value. This method is typically used for looking up the current version ID of a versioned entity.
func (MemTable[T]) ReadNumericValue ¶
func (table MemTable[T]) ReadNumericValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (NumValue, error)
ReadNumericValue reads the specified numeric value from the specified row.
func (MemTable[T]) ReadNumericValueRange ¶ added in v1.4.0
func (table MemTable[T]) ReadNumericValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]NumValue, error)
ReadNumericValueRange reads a range of numeric values from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadNumericValues ¶
func (table MemTable[T]) ReadNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]NumValue, error)
ReadNumericValues reads paginated numeric values from the specified row.
func (MemTable[T]) ReadPartKeyLabel ¶ added in v1.3.0
func (table MemTable[T]) ReadPartKeyLabel(ctx context.Context, row TableRow[T], partKeyValue string) (TextValue, error)
ReadPartKeyLabel reads the text label for the specified partition key value from the specified row.
func (MemTable[T]) ReadPartKeyLabelRange ¶ added in v1.4.0
func (table MemTable[T]) ReadPartKeyLabelRange(ctx context.Context, row TableRow[T], from, to string, reverse bool) ([]TextValue, error)
ReadPartKeyLabelRange reads a range of partition key labels from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadPartKeyLabels ¶ added in v1.3.0
func (table MemTable[T]) ReadPartKeyLabels(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]TextValue, error)
ReadPartKeyLabels reads paginated partition key labels from the specified row.
func (MemTable[T]) ReadPartKeyValueRange ¶ added in v1.4.0
func (table MemTable[T]) ReadPartKeyValueRange(ctx context.Context, row TableRow[T], from string, to string, reverse bool) ([]string, error)
ReadPartKeyValueRange reads a range of partition key values for the specified row, where the partition key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadPartKeyValues ¶
func (table MemTable[T]) ReadPartKeyValues(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]string, error)
ReadPartKeyValues reads paginated partition key values for the specified row.
func (MemTable[T]) ReadRecord ¶ added in v1.2.0
func (table MemTable[T]) ReadRecord(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (Record, error)
ReadRecord reads the specified Record from the specified row.
func (MemTable[T]) ReadRecordRange ¶ added in v1.4.0
func (table MemTable[T]) ReadRecordRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]Record, error)
ReadRecordRange reads a range of Records from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadRecords ¶ added in v1.2.0
func (table MemTable[T]) ReadRecords(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]Record, error)
ReadRecords reads paginated Records from the specified row.
func (MemTable[T]) ReadSortKeyValueRange ¶ added in v1.4.0
func (table MemTable[T]) ReadSortKeyValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from string, to string, reverse bool) ([]string, error)
ReadSortKeyValueRange reads a range of sort key values for the specified row and partition key value, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadSortKeyValues ¶
func (table MemTable[T]) ReadSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]string, error)
ReadSortKeyValues reads paginated sort key values for the specified row and partition key value, where the sort key values are returned in ascending or descending order. The offset is the last sort key value returned in the previous page of results. If the offset is empty, it will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadTextValue ¶
func (table MemTable[T]) ReadTextValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (TextValue, error)
ReadTextValue reads the specified text value from the specified row.
func (MemTable[T]) ReadTextValueRange ¶ added in v1.4.0
func (table MemTable[T]) ReadTextValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]TextValue, error)
ReadTextValueRange reads a range of text values from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (MemTable[T]) ReadTextValues ¶
func (table MemTable[T]) ReadTextValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]TextValue, error)
ReadTextValues reads paginated text values from the specified row.
func (MemTable[T]) TableExists ¶
TableExists returns true if the in-memory table exists.
func (MemTable[T]) UpdateEntity ¶
UpdateEntity batch-writes the provided entity to each of the wide rows in the table, including deleting any obsolete values in index rows.
func (MemTable[T]) UpdateEntityVersion ¶
UpdateEntityVersion batch-writes the provided entity to each of the wide rows in the table, including deleting any obsolete values in index rows.
type Record ¶
type Record struct { PartKeyValue string SortKeyValue string JsonValue []byte TextValue string NumericValue float64 TimeToLive int64 }
Record is a struct that represents a single item in a database table. PartKeyValue and SortKeyValue are used to represent the primary key and are required fields. All other fields are optional. Note that the PartKeyValue will be a full pipe-delimited partition key: rowName|partKeyName|partKeyValue.
type RecordSet ¶
RecordSet provides an in-memory data structure for storing a set of Records, used for lightweight testing purposes.
func (*RecordSet) CountSortKeys ¶ added in v1.3.0
CountSortKeys returns the total number of sort keys for a specified partition key.
func (*RecordSet) DeleteRecord ¶
DeleteRecord removes the provided Record from the RecordSet.
func (*RecordSet) DeleteRecordForKeys ¶
DeleteRecordForKeys removes a specified Record from the RecordSet.
func (*RecordSet) DeleteRecords ¶
DeleteRecords removes the provided list of Records from the RecordSet.
func (*RecordSet) DeleteRecordsForKey ¶
DeleteRecordsForKey removes all Records for a specified partition key from the RecordSet.
func (*RecordSet) GetRecords ¶
GetRecords returns a list of Records from the RecordSet.
func (*RecordSet) GetSortKeys ¶
GetSortKeys returns a complete list of sort keys for a specified partition key.
func (*RecordSet) RecordExists ¶
RecordExists returns true if the RecordSet contains a record for the provided partition and sort key.
func (*RecordSet) RecordsExist ¶
RecordsExist returns true if the RecordSet contains any records for the provided partition key.
func (*RecordSet) SetRecords ¶
SetRecords adds a list of Records to the RecordSet.
type Table ¶
type Table[T any] struct { Client *dynamodb.Client // AWS DynamoDB client EntityType string // the type of entity stored in this table TableName string // name of the table, typically including the entity type and environment name PartKeyAttr string // partition key attribute name (e.g. "v_part") SortKeyAttr string // sort key attribute name (e.g. "v_sort") JsonValueAttr string // JSON value attribute name (e.g. "v_json") TextValueAttr string // text value attribute name (e.g. "v_text") NumericValueAttr string // numeric value attribute name (e.g. "v_num") TimeToLiveAttr string // time to live attribute name (e.g. "v_expires") TTL bool // true if the table has a time to live attribute EntityRow TableRow[T] // the row that stores the entity versions IndexRows map[string]TableRow[T] // index rows, based on various entity properties }
Table represents a single DynamoDB table that stores all the "wide rows" for a given entity. Denormalized entity data are stored in a single table, reusing the attribute names indicated in the Table definition. The EntityRow is special; it contains the revision history for the entity, whereas the IndexRows contain only values from the latest revision of the entity.
func (Table[T]) CountPartKeyValues ¶ added in v1.3.0
CountPartKeyValues returns the total number of partition key values in the specified row. Note that this may be a slow operation; it pages through all the values to count them.
func (Table[T]) CountSortKeyValues ¶ added in v1.3.0
func (table Table[T]) CountSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) (int64, error)
CountSortKeyValues returns the total number of sort key values for the specified row and partition key value. Note that this may be a slow operation; it pages through all the values to count them.
func (Table[T]) CreateTable ¶
CreateTable creates the DynamoDB table for the entity. This operation may take a few seconds to complete, as it waits for the table to become active.
func (Table[T]) DeleteEntity ¶
DeleteEntity deletes the provided entity from the table (including all versions).
func (Table[T]) DeleteEntityVersionWithID ¶ added in v1.3.0
func (table Table[T]) DeleteEntityVersionWithID(ctx context.Context, entityID, versionID string) (T, error)
DeleteEntityVersionWithID deletes the specified version of the entity from the table.
func (Table[T]) DeleteEntityWithID ¶
DeleteEntityWithID deletes the specified entity from the table (including all versions).
func (Table[T]) DeleteItem ¶
func (table Table[T]) DeleteItem(ctx context.Context, rowPartKeyValue string, sortKeyValue string) error
DeleteItem deletes the item with the specified row partition key and sort key. Note that this method will seldom be used, perhaps for cleaning up obsolete items.
func (Table[T]) DeleteTable ¶
DeleteTable deletes the DynamoDB table. Note that the table's status may be DELETING for a few seconds.
func (Table[T]) EntityExists ¶
EntityExists checks if an entity exists in the table.
func (Table[T]) EntityID ¶ added in v1.2.0
EntityID returns the unique entity ID for the provided entity.
func (Table[T]) EntityReferenceID ¶ added in v1.2.0
EntityReferenceID returns a unique Reference ID (EntityType-ID-VersionID) for the provided entity.
func (Table[T]) EntityVersionExists ¶
func (table Table[T]) EntityVersionExists(ctx context.Context, entityID string, versionID string) bool
EntityVersionExists checks if an entity version exists in the table.
func (Table[T]) EntityVersionID ¶ added in v1.2.0
EntityVersionID returns the unique entity version ID for the provided entity.
func (Table[T]) FilterEntityLabels ¶ added in v1.3.0
func (table Table[T]) FilterEntityLabels(ctx context.Context, f func(TextValue) bool) ([]TextValue, error)
FilterEntityLabels returns all entity labels that match the specified filter. The resulting text values are sorted by value.
func (Table[T]) FilterPartKeyLabels ¶ added in v1.3.0
func (table Table[T]) FilterPartKeyLabels(ctx context.Context, row TableRow[T], f func(TextValue) bool) ([]TextValue, error)
FilterPartKeyLabels returns all partition key labels from the specified row that match the specified filter. The resulting text values are sorted by value.
func (Table[T]) FilterTextValues ¶ added in v1.3.0
func (table Table[T]) FilterTextValues(ctx context.Context, row TableRow[T], partKeyValue string, f func(TextValue) bool) ([]TextValue, error)
FilterTextValues returns all text values from the specified row that match the specified filter. The resulting text values are sorted by value.
func (Table[T]) GetEntityRow ¶
GetEntityRow returns the entity row definition. This row contains the revision history for the entity.
func (Table[T]) GetEntityType ¶ added in v1.3.0
GetEntityType returns the name of the entity type stored in this table.
func (Table[T]) GetTableDescription ¶
GetTableDescription fetches metadata about the DynamoDB table.
func (Table[T]) GetTableName ¶ added in v1.3.0
GetTableName returns the name of the table.
func (Table[T]) IsValid ¶ added in v1.2.0
IsValid returns true if the table fields and rows are valid.
func (Table[T]) ReadAllEntitiesFromRow ¶
func (table Table[T]) ReadAllEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string) ([]T, error)
ReadAllEntitiesFromRow reads all entities from the specified row. Note: this could be a lot of data! It should only be used for small collections.
func (Table[T]) ReadAllEntitiesFromRowAsJSON ¶ added in v1.1.0
func (table Table[T]) ReadAllEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string) ([]byte, error)
ReadAllEntitiesFromRowAsJSON reads all entities from the specified row as a JSON byte slice. Note: this could be a lot of data! It should only be used for small collections.
func (Table[T]) ReadAllEntityIDs ¶
ReadAllEntityIDs reads all entity IDs from the EntityRow. Note that this can return a very large number of IDs!
func (Table[T]) ReadAllEntityLabels ¶ added in v1.3.0
func (table Table[T]) ReadAllEntityLabels(ctx context.Context, sortByValue bool) ([]TextValue, error)
ReadAllEntityLabels reads all entity labels. Note: this can return a very large number of values! Use with caution.
func (Table[T]) ReadAllEntityVersionIDs ¶
func (table Table[T]) ReadAllEntityVersionIDs(ctx context.Context, entityID string) ([]string, error)
ReadAllEntityVersionIDs reads all entity version IDs for the specified entity. Note that this can return a very large number of IDs!
func (Table[T]) ReadAllEntityVersions ¶
ReadAllEntityVersions reads all versions of the specified entity. Note: this can return a very large number of versions! Use with caution.
func (Table[T]) ReadAllEntityVersionsAsJSON ¶ added in v1.1.0
func (table Table[T]) ReadAllEntityVersionsAsJSON(ctx context.Context, entityID string) ([]byte, error)
ReadAllEntityVersionsAsJSON reads all versions of the specified entity as a JSON byte slice. Note: this can return a very large number of versions! Use with caution.
func (Table[T]) ReadAllNumericValues ¶
func (table Table[T]) ReadAllNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]NumValue, error)
ReadAllNumericValues reads all numeric values from the specified row. Note: this can return a very large number of values! Use with caution.
func (Table[T]) ReadAllPartKeyLabels ¶ added in v1.3.0
func (table Table[T]) ReadAllPartKeyLabels(ctx context.Context, row TableRow[T], sortByValue bool) ([]TextValue, error)
ReadAllPartKeyLabels reads all partition key labels from the specified row. Note: this can return a very large number of values! Use with caution.
func (Table[T]) ReadAllPartKeyValues ¶
ReadAllPartKeyValues reads all the values of the partition keys used for the specified row. Note that for some rows, this may be a very large number of values.
func (Table[T]) ReadAllRecords ¶ added in v1.2.0
func (table Table[T]) ReadAllRecords(ctx context.Context, row TableRow[T], partKeyValue string) ([]Record, error)
ReadAllRecords reads all Records from the specified row. Note: this can return a very large number of values! Use with caution.
func (Table[T]) ReadAllSortKeyValues ¶
func (table Table[T]) ReadAllSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) ([]string, error)
ReadAllSortKeyValues reads all the sort key values for the specified row and partition key value. Note that for some rows, this may be a very large number of values.
func (Table[T]) ReadAllTextValues ¶
func (table Table[T]) ReadAllTextValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]TextValue, error)
ReadAllTextValues reads all text values from the specified row. Note: this can return a very large number of values! Use with caution.
func (Table[T]) ReadCurrentEntityVersionID ¶
func (table Table[T]) ReadCurrentEntityVersionID(ctx context.Context, entityID string) (string, error)
ReadCurrentEntityVersionID reads the current entity version ID for the specified entity.
func (Table[T]) ReadEntities ¶
ReadEntities reads the current versions of the specified entities from the EntityRow. If an entity does not exist, it will be omitted from the results.
func (Table[T]) ReadEntitiesAsJSON ¶ added in v1.1.0
ReadEntitiesAsJSON reads the current versions of the specified entities from the EntityRow as a JSON byte slice. If an entity does not exist, it will be omitted from the results.
func (Table[T]) ReadEntitiesFromRow ¶
func (table Table[T]) ReadEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]T, error)
ReadEntitiesFromRow reads paginated entities from the specified row.
func (Table[T]) ReadEntitiesFromRowAsJSON ¶ added in v1.1.0
func (table Table[T]) ReadEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]byte, error)
ReadEntitiesFromRowAsJSON reads paginated entities from the specified row, returning a JSON byte slice.
func (Table[T]) ReadEntity ¶
ReadEntity reads the current version of the specified entity.
func (Table[T]) ReadEntityAsCompressedJSON ¶ added in v1.1.0
func (table Table[T]) ReadEntityAsCompressedJSON(ctx context.Context, entityID string) ([]byte, error)
ReadEntityAsCompressedJSON reads the current version of the specified entity, returning a compressed JSON byte slice.
func (Table[T]) ReadEntityAsJSON ¶ added in v1.1.0
ReadEntityAsJSON reads the current version of the specified entity as a JSON byte slice.
func (Table[T]) ReadEntityFromRow ¶
func (table Table[T]) ReadEntityFromRow(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (T, error)
ReadEntityFromRow reads the specified entity from the specified row.
func (Table[T]) ReadEntityFromRowAsCompressedJSON ¶ added in v1.1.0
func (table Table[T]) ReadEntityFromRowAsCompressedJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
ReadEntityFromRowAsCompressedJSON reads the specified entity from the specified row as compressed JSON bytes.
func (Table[T]) ReadEntityFromRowAsJSON ¶ added in v1.1.0
func (table Table[T]) ReadEntityFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error)
ReadEntityFromRowAsJSON reads the specified entity from the specified row as JSON bytes.
func (Table[T]) ReadEntityIDRange ¶ added in v1.4.0
func (table Table[T]) ReadEntityIDRange(ctx context.Context, from string, to string, reverse bool) ([]string, error)
ReadEntityIDRange reads a range of entity IDs from the EntityRow, where the entity IDs range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadEntityIDs ¶
func (table Table[T]) ReadEntityIDs(ctx context.Context, reverse bool, limit int, offset string) ([]string, error)
ReadEntityIDs reads paginated entity IDs from the EntityRow.
func (Table[T]) ReadEntityLabel ¶ added in v1.3.0
ReadEntityLabel reads the label for the specified entity.
func (Table[T]) ReadEntityLabelRange ¶ added in v1.4.0
func (table Table[T]) ReadEntityLabelRange(ctx context.Context, from, to string, reverse bool) ([]TextValue, error)
ReadEntityLabelRange reads a range of entity labels, where the entity IDs range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadEntityLabels ¶ added in v1.3.0
func (table Table[T]) ReadEntityLabels(ctx context.Context, reverse bool, limit int, offset string) ([]TextValue, error)
ReadEntityLabels reads paginated entity labels.
func (Table[T]) ReadEntityRangeFromRow ¶ added in v1.4.0
func (table Table[T]) ReadEntityRangeFromRow(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]T, error)
ReadEntityRangeFromRow reads a range of entities from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadEntityRangeFromRowAsJSON ¶ added in v1.4.0
func (table Table[T]) ReadEntityRangeFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]byte, error)
ReadEntityRangeFromRowAsJSON reads a range of entities from the specified row as JSON, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadEntityVersion ¶
func (table Table[T]) ReadEntityVersion(ctx context.Context, entityID string, versionID string) (T, error)
ReadEntityVersion reads the specified version of the specified entity.
func (Table[T]) ReadEntityVersionAsJSON ¶ added in v1.1.0
func (table Table[T]) ReadEntityVersionAsJSON(ctx context.Context, entityID string, versionID string) ([]byte, error)
ReadEntityVersionAsJSON reads the specified version of the specified entity as a JSON byte slice.
func (Table[T]) ReadEntityVersionIDs ¶
func (table Table[T]) ReadEntityVersionIDs(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]string, error)
ReadEntityVersionIDs reads paginated entity version IDs for the specified entity.
func (Table[T]) ReadEntityVersions ¶
func (table Table[T]) ReadEntityVersions(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]T, error)
ReadEntityVersions reads paginated versions of the specified entity.
func (Table[T]) ReadEntityVersionsAsJSON ¶ added in v1.1.0
func (table Table[T]) ReadEntityVersionsAsJSON(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]byte, error)
ReadEntityVersionsAsJSON reads paginated versions of the specified entity as a JSON byte slice.
func (Table[T]) ReadFirstSortKeyValue ¶ added in v1.2.0
func (table Table[T]) ReadFirstSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
ReadFirstSortKeyValue reads the first sort key value for the specified row and partition key value. This method is typically used for looking up an ID corresponding to a foreign key.
func (Table[T]) ReadLastSortKeyValue ¶ added in v1.2.0
func (table Table[T]) ReadLastSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error)
ReadLastSortKeyValue reads the last sort key value for the specified row and partition key value. This method is typically used for looking up the current version ID of a versioned entity.
func (Table[T]) ReadNumericValue ¶
func (table Table[T]) ReadNumericValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (NumValue, error)
ReadNumericValue reads the specified numeric value from the specified row.
func (Table[T]) ReadNumericValueRange ¶ added in v1.4.0
func (table Table[T]) ReadNumericValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]NumValue, error)
ReadNumericValueRange reads a range of numeric values from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadNumericValues ¶
func (table Table[T]) ReadNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]NumValue, error)
ReadNumericValues reads paginated numeric values from the specified row.
func (Table[T]) ReadPartKeyLabel ¶ added in v1.3.0
func (table Table[T]) ReadPartKeyLabel(ctx context.Context, row TableRow[T], partKeyValue string) (TextValue, error)
ReadPartKeyLabel reads the text label for the specified partition key value from the specified row.
func (Table[T]) ReadPartKeyLabelRange ¶ added in v1.4.0
func (table Table[T]) ReadPartKeyLabelRange(ctx context.Context, row TableRow[T], from, to string, reverse bool) ([]TextValue, error)
ReadPartKeyLabelRange reads a range of partition key labels from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadPartKeyLabels ¶ added in v1.3.0
func (table Table[T]) ReadPartKeyLabels(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]TextValue, error)
ReadPartKeyLabels reads paginated partition key labels from the specified row.
func (Table[T]) ReadPartKeyValueRange ¶ added in v1.4.0
func (table Table[T]) ReadPartKeyValueRange(ctx context.Context, row TableRow[T], from string, to string, reverse bool) ([]string, error)
ReadPartKeyValueRange reads a range of partition key values for the specified row.
func (Table[T]) ReadPartKeyValues ¶
func (table Table[T]) ReadPartKeyValues(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]string, error)
ReadPartKeyValues reads paginated partition key values for the specified row.
func (Table[T]) ReadRecord ¶ added in v1.2.0
func (table Table[T]) ReadRecord(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (Record, error)
ReadRecord reads the specified record from the provided table row.
func (Table[T]) ReadRecordRange ¶ added in v1.4.0
func (table Table[T]) ReadRecordRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]Record, error)
ReadRecordRange reads a range of Records from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadRecords ¶ added in v1.2.0
func (table Table[T]) ReadRecords(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]Record, error)
ReadRecords reads paginated Records from the specified row.
func (Table[T]) ReadSortKeyValueRange ¶ added in v1.4.0
func (table Table[T]) ReadSortKeyValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from string, to string, reverse bool) ([]string, error)
ReadSortKeyValueRange reads a range of sort key values for the specified row and partition key value, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadSortKeyValues ¶
func (table Table[T]) ReadSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]string, error)
ReadSortKeyValues reads paginated sort key values for the specified row and partition key value.
func (Table[T]) ReadTextValue ¶
func (table Table[T]) ReadTextValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (TextValue, error)
ReadTextValue reads the specified text value from the specified row.
func (Table[T]) ReadTextValueRange ¶ added in v1.4.0
func (table Table[T]) ReadTextValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]TextValue, error)
ReadTextValueRange reads a range of text values from the specified row, where the sort key values range between the specified inclusive 'from' and 'to' values. If either 'from' or 'to' are empty, they will be replaced with the appropriate sentinel value.
func (Table[T]) ReadTextValues ¶
func (table Table[T]) ReadTextValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]TextValue, error)
ReadTextValues reads paginated text values from the specified row.
func (Table[T]) TableExists ¶
TableExists returns true if the DynamoDB table exists.
func (Table[T]) UpdateEntity ¶
UpdateEntity batch-writes the provided entity to each of the wide rows in the table, including deleting any obsolete values in index rows. If a previous version does not exist, it is treated as a new entity.
func (Table[T]) UpdateEntityVersion ¶
UpdateEntityVersion batch-writes the provided entity to each of the wide rows in the table, including deleting any obsolete values in index rows.
type TableReadWriter ¶
type TableReadWriter[T any] interface { TableReader[T] TableWriter[T] }
TableReadWriter is both a TableReader and TableWriter
type TableReader ¶
type TableReader[T any] interface { IsValid() bool GetEntityType() string GetTableName() string GetRow(rowName string) (TableRow[T], bool) GetEntityRow() TableRow[T] EntityID(entity T) string EntityVersionID(entity T) string EntityReferenceID(entity T) string EntityExists(ctx context.Context, entityID string) bool EntityVersionExists(ctx context.Context, entityID string, versionID string) bool CountPartKeyValues(ctx context.Context, row TableRow[T]) (int64, error) CountSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) (int64, error) ReadAllPartKeyValues(ctx context.Context, row TableRow[T]) ([]string, error) ReadAllSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string) ([]string, error) ReadPartKeyValues(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]string, error) ReadPartKeyValueRange(ctx context.Context, row TableRow[T], from string, to string, reverse bool) ([]string, error) ReadSortKeyValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]string, error) ReadSortKeyValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from string, to string, reverse bool) ([]string, error) ReadFirstSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error) ReadLastSortKeyValue(ctx context.Context, row TableRow[T], partKeyValue string) (string, error) ReadAllEntityIDs(ctx context.Context) ([]string, error) ReadEntityIDs(ctx context.Context, reverse bool, limit int, offset string) ([]string, error) ReadEntityIDRange(ctx context.Context, from string, to string, reverse bool) ([]string, error) ReadAllEntityVersionIDs(ctx context.Context, entityID string) ([]string, error) ReadEntityVersionIDs(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]string, error) ReadCurrentEntityVersionID(ctx context.Context, entityID string) (string, error) ReadEntities(ctx context.Context, entityIDs []string) []T ReadEntitiesAsJSON(ctx context.Context, entityIDs []string) []byte ReadEntity(ctx context.Context, entityID string) (T, error) ReadEntityAsJSON(ctx context.Context, entityID string) ([]byte, error) ReadEntityAsCompressedJSON(ctx context.Context, entityID string) ([]byte, error) ReadEntityVersion(ctx context.Context, entityID string, versionID string) (T, error) ReadEntityVersionAsJSON(ctx context.Context, entityID string, versionID string) ([]byte, error) ReadEntityVersions(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]T, error) ReadEntityVersionsAsJSON(ctx context.Context, entityID string, reverse bool, limit int, offset string) ([]byte, error) ReadAllEntityVersions(ctx context.Context, entityID string) ([]T, error) ReadAllEntityVersionsAsJSON(ctx context.Context, entityID string) ([]byte, error) ReadEntityFromRow(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (T, error) ReadEntityFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error) ReadEntityFromRowAsCompressedJSON(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) ([]byte, error) ReadEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]T, error) ReadEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]byte, error) ReadEntityRangeFromRow(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]T, error) ReadEntityRangeFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]byte, error) ReadAllEntitiesFromRow(ctx context.Context, row TableRow[T], partKeyValue string) ([]T, error) ReadAllEntitiesFromRowAsJSON(ctx context.Context, row TableRow[T], partKeyValue string) ([]byte, error) ReadRecord(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (Record, error) ReadRecords(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]Record, error) ReadRecordRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]Record, error) ReadAllRecords(ctx context.Context, row TableRow[T], partKeyValue string) ([]Record, error) ReadEntityLabel(ctx context.Context, entityID string) (TextValue, error) ReadEntityLabels(ctx context.Context, reverse bool, limit int, offset string) ([]TextValue, error) ReadEntityLabelRange(ctx context.Context, from, to string, reverse bool) ([]TextValue, error) ReadAllEntityLabels(ctx context.Context, sortByValue bool) ([]TextValue, error) FilterEntityLabels(ctx context.Context, f func(TextValue) bool) ([]TextValue, error) ReadPartKeyLabel(ctx context.Context, row TableRow[T], partKeyValue string) (TextValue, error) ReadPartKeyLabels(ctx context.Context, row TableRow[T], reverse bool, limit int, offset string) ([]TextValue, error) ReadPartKeyLabelRange(ctx context.Context, row TableRow[T], from, to string, reverse bool) ([]TextValue, error) ReadAllPartKeyLabels(ctx context.Context, row TableRow[T], sortByValue bool) ([]TextValue, error) FilterPartKeyLabels(ctx context.Context, row TableRow[T], f func(TextValue) bool) ([]TextValue, error) ReadTextValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (TextValue, error) ReadTextValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]TextValue, error) ReadTextValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]TextValue, error) ReadAllTextValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]TextValue, error) FilterTextValues(ctx context.Context, row TableRow[T], partKeyValue string, f func(TextValue) bool) ([]TextValue, error) ReadNumericValue(ctx context.Context, row TableRow[T], partKeyValue string, sortKeyValue string) (NumValue, error) ReadNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, reverse bool, limit int, offset string) ([]NumValue, error) ReadNumericValueRange(ctx context.Context, row TableRow[T], partKeyValue string, from, to string, reverse bool) ([]NumValue, error) ReadAllNumericValues(ctx context.Context, row TableRow[T], partKeyValue string, sortByValue bool) ([]NumValue, error) }
TableReader is the interface that defines methods for reading entity-related information from a DynamoDB table based on an opinionated implementation of DynamoDB by Table.
type TableRow ¶
type TableRow[T any] struct { RowName string PartKeyName string PartKeyValue func(T) string PartKeyValues func(T) []string PartKeyLabel func(T) string SortKeyName string SortKeyValue func(T) string JsonValue func(T) []byte TextValue func(T) string NumericValue func(T) float64 TimeToLive func(T) int64 }
TableRow represents a single "wide row" in an Entity Table. A "wide row" is used to quickly provide a response to a specific query, or question for the data. Example: "What error events occurred on this day?"
The following attributes are stored in the table. These attribute names are configurable.
- v_part: partition key (required)
- v_sort: sorting key (required; for an entity row without versions, reuse the partition key)
- v_json: gzip compressed JSON data (optional)
- v_text: string value (optional)
- v_num: double-wide floating point numeric value (optional)
- v_expires: expiration timestamp in epoch seconds (optional)
Pipe-separated key values are used to avoid naming collisions, supporting multiple row types in a single table: Entity Values: rowName|partKeyName|partKeyValue -- (sortKeyValue, value), (sortKeyValue, value), ... Partition Keys: rowName|partKeyName -- (partKeyValue, label), (partKeyValue, label), ... Note that in addition to storing the entity data in a given row, we're also storing the partition key values used for each row, to support queries that "walk" the entire data set for a given row type.
type TableWriter ¶
type TableWriter[T any] interface { WriteEntity(ctx context.Context, entity T) error UpdateEntity(ctx context.Context, entity T) error UpdateEntityVersion(ctx context.Context, oldVersion T, newVersion T) error DeleteEntity(ctx context.Context, entity T) error DeleteEntityWithID(ctx context.Context, entityID string) (T, error) DeleteEntityVersionWithID(ctx context.Context, entityID, versionID string) (T, error) }
TableWriter is the interface that defines methods for writing, updating, or deleting an entity from a DynamoDB table based on an opinionated implementation of DynamoDB by Table.
type TextValue ¶
TextValue represents a key-value pair where the value is a string.
func (TextValue) ContainsAll ¶ added in v1.3.0
ContainsAll returns true if the Value contains all the terms (an AND filter). The terms should be lowercase for a case-insensitive search.
func (TextValue) ContainsAny ¶ added in v1.3.0
ContainsAny returns true if the Value contains any of the terms (an OR filter). The terms should be lowercase for a case-insensitive search.