db

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("error row not found")
)

Functions

This section is empty.

Types

type DB

type DB[T Storable] interface {
	Insert(obj T)
	Update(obj T)
	Delete(key string) T
	Get(key string) (T, error)
	GetAll() ([]T, error)
}

func CreateDB

func CreateDB[T Storable](table string, url string) (DB[T], error)

type Dynamo

type Dynamo[T StorableDynamo] struct {
	// contains filtered or unexported fields
}

func CreateDynamoTable

func CreateDynamoTable[T StorableDynamo](tableName string, db *dynamo.DB) (Dynamo[T], error)

func (*Dynamo[T]) Delete

func (d *Dynamo[T]) Delete(hash string) (T, error)

func (*Dynamo[T]) Get

func (d *Dynamo[T]) Get(hash string) (T, error)

func (*Dynamo[T]) Put

func (d *Dynamo[T]) Put(item T) error

type DynamoTable

type DynamoTable[T StorableDynamo] interface {
	Put(item T) error
	Get(hash string) (T, error)
	Delete(hash string) (T, error)
}

type Storable

type Storable interface {
	GetPrimaryKey() string
}

type StorableDynamo

type StorableDynamo interface {
	GetTableId() string
}

type StorableIndex

type StorableIndex interface {
	Storable
	GetSecondaryKey() string
}

type WithIndex

type WithIndex[T StorableIndex] interface {
	DB[T]
	GetBoth(key, secondary string) (T, error)
	GetSecondary(secondary string) ([]T, error)
	DeleteSpecific(key string, secondaryKey string) T
	GetPrimary(key string) ([]T, error)
}

func CreateDBWithIndex

func CreateDBWithIndex[T StorableIndex](table string, url string) (WithIndex[T], error)

Jump to

Keyboard shortcuts

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