dynamodbsaas

package
v0.0.0-...-f5b340a Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

package dy is a set of utility for DynamoDb to be able to work in a multiaccount environment

Index

Constants

View Source
const (
	EntityMappingError errors.TraceableType = "EntityMappingError"
)
View Source
const MarshalingError errors.TraceableType = "MarshalingError"

Variables

This section is empty.

Functions

func DeserializeKey

func DeserializeKey(key string) (map[string]*dynamodb.AttributeValue, error)

func DynamoDbInstance

func DynamoDbInstance() *dynamodb.DynamoDB

func SerializeKey

func SerializeKey(data map[string]*dynamodb.AttributeValue) (string, error)

func StdDFWrapperAccountModel

func StdDFWrapperAccountModel(skPrefix string, da map[string]DynamicAttrFunc)

StdDFWrapperAccountModel is a wrapper that adds "Standard" dynamic fields

func StdDFWrapperAccountUserModel

func StdDFWrapperAccountUserModel(pkPrefix string, skPrefix string, da map[string]DynamicAttrFunc)

StdDFWrapperAccountUserModel is a wrapper that adds "Standard" dynamic fields

func StdDFWrapperSharedModel

func StdDFWrapperSharedModel(pkPrefix string, skPrefix string, da map[string]DynamicAttrFunc)

StdDFWrapperSharedModel is a wrapper that adds "Standard" dynamic fields

func StdDFWrapperUserModel

func StdDFWrapperUserModel(pkPrefix string, skPrefix string, da map[string]DynamicAttrFunc)

StdDFWrapperUserModel is a wrapper that adds "Standard" dynamic fields

func TableNameWithEnv

func TableNameWithEnv(tableName string) string

Types

type Db

type Db struct {
	DynamoDb                *dynamodb.DynamoDB
	TableName               string
	EntityDescriptorMapping map[reflect.Type]*EntityDescriptor
	db.Getter
	db.Creator
	db.Deleter
	db.Updater
	db.CursorLister
}

func (*Db) Create

func (r *Db) Create(ctx context.Context, id t.String, data interface{}) error

Create instance entity data in Dynamodb table

func (*Db) CursorList

func (r *Db) CursorList(ctx context.Context, startAtKey string, limit int64, out interface{}) (*db.CursorListResult, error)

CursorList retrieves data from repository and returns as cursor

func (*Db) Delete

func (r *Db) Delete(ctx context.Context, id t.String, out interface{}) error

Delete data from repository

func (*Db) Get

func (r *Db) Get(ctx context.Context, id t.String, out interface{}) error

Get data from repository

func (*Db) GetEntityDescriptor

func (r *Db) GetEntityDescriptor(data interface{}) (*EntityDescriptor, error)

func (*Db) InternalCursorList

func (r *Db) InternalCursorList(ctx context.Context, input *dynamodb.QueryInput, startAtKey string, limit int64, out interface{}) (*db.CursorListResult, error)

func (*Db) MarshalMap

func (r *Db) MarshalMap(c context.Context, id t.String, data interface{}) (map[string]*dynamodb.AttributeValue, error)

MarshalMap execute wrapper on the object

func (*Db) Update

func (r *Db) Update(ctx context.Context, id t.String, data interface{}) error

Update data into repository

type DynamicAttrFunc

type DynamicAttrFunc func(ctx context.Context, model interface{}) (interface{}, error)

type DynamoSaasModel

type DynamoSaasModel struct {
	db.SaasModel
	UpdatedAt int64
	CreatedAt int64
}

type EntityDescriptor

type EntityDescriptor struct {
	DynamicFields map[string]DynamicAttrFunc
	IDBuilder     IDBuilderFunc
	PK            *Index
}

type IDBuilderFunc

type IDBuilderFunc func(ctx context.Context, id t.String) map[string]*dynamodb.AttributeValue

func StdIDBuilderAccountModel

func StdIDBuilderAccountModel(skPrefix string) IDBuilderFunc

StdIDBuilderAccountModel build the standard ids

func StdIDBuilderAccountUserModel

func StdIDBuilderAccountUserModel(skPrefix string) IDBuilderFunc

StdIDBuilderAccountUserModel build the standard ids

func StdIDBuilderSharedModel

func StdIDBuilderSharedModel(pkPrefix string, skPrefix string) IDBuilderFunc

StdIDBuilderSharedModel build the standard ids

func StdIDBuilderUserModel

func StdIDBuilderUserModel(skPrefix string) IDBuilderFunc

StdIDBuilderUserModel build the standard ids

type Index

type Index struct {
	PkField string
	SkField string
}

Jump to

Keyboard shortcuts

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