entities

package
v0.0.0-...-cfd4cc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateItem

func CreateItem(service dynamodb.DynamoDB, item Item, tableName string) error

Crate a new item in dynamodb

Types

type Item

type Item interface {
	GetPK() *string                                         // Get the partition key
	GetSK() *string                                         // Get the sort key
	Keys() map[string]*dynamodb.AttributeValue              // Get the DynamoDB keys (PK and SK)
	ToItem() map[string]*dynamodb.AttributeValue            // Get the DynamoDB item
	FromItem(item map[string]*dynamodb.AttributeValue) Item // Get the Item from the DynamoDB item
}

Item is an abstract type for DynamoDB items

type User

type User struct {
	Name  *string `json:"name"`
	Email *string `json:"email"`
}

User is a struct that implements the Item interface

func (User) FromItem

func (user User) FromItem(item map[string]*dynamodb.AttributeValue) Item

FromItem returns the UserItem from the DynamoDB Item

func (User) GetPK

func (user User) GetPK() *string

GetPK returns the partition key for the user item

func (User) GetSK

func (user User) GetSK() *string

GetSK returns the sort key for the user item

func (User) Keys

func (user User) Keys() map[string]*dynamodb.AttributeValue

Keys returns the DynamoDB keys for the user item

func (User) ToItem

func (user User) ToItem() map[string]*dynamodb.AttributeValue

ToItem returns the DynamoDB item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL