ddb

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

ddb

Helper types for writing expression DynamoDB code

backlog

  • SHOULD panic/error if a "op" is used after running it
  • COULD add an option that always runs singleton operations in a transaction alsop
  • COULD add option for consisten read
  • COULD add option for ReturnConsumedCapacity
  • COULD make Do return an TXDB-like interface for composability of operations
  • COULD turn a set of Put, and Deletes into a BatchWriteRequest as well
  • COULD turn a set Get requests into a BatchGetItem/BatchWriteItem request
  • SHOULD support "ReturnValues" while wi.Put/Delete/Update doesn't support it
  • COULD create error types that show the dynamodb input for debugging
  • COULD be nice to have an helper that decodes the whole result into a slice of entities
  • COULD be nice to have an helper that decodes the result with the expectation there is only one item
  • COULD share more code between QueryResult and ScanResult

notes

  • A Query, Scan, Put, Get, Delete, Update and ConditionCheck only variables in an operations are:
    • The dynamodb.QueryInput, dynamodb.Put...
    • The expression.Builder
    • The Item/Key
  • There is "QueryPages" already
  • There is "ScanPages" already

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalAll added in v0.6.0

func UnmarshalAll(r Result, v interface{}) (err error)

UnmarshalAll will run through all results in 'r' and unmarshal all items into 'v'. It will consume the result in the process and it cannot scanned again afterwards. Each element of v must implement the Itemizer and Deitemizer interface.

Types

type Deitemizer

type Deitemizer interface {
	FromItem(Item)
}

type Dynamo

Dynamo describes the strict sub-set official DynamoDB interface that this library uses.

type Item

type Item interface {
	Keys() (pk, sk string)
}

type Itemizer

type Itemizer interface {
	Item() Item
}

type Querier

type Querier struct {
	// contains filtered or unexported fields
}

Querier holds a DynamoDB query

func Query

func Query(b expression.Builder, in dynamodb.QueryInput) (q *Querier)

Query sets up a query that can be run to fetch

func (*Querier) Run

func (q *Querier) Run(ctx context.Context, ddb Dynamo) (r Result, err error)

Run will return a Query result for iteration

type Reader added in v0.6.0

type Reader struct {
	// contains filtered or unexported fields
}

Reader represents one or more read to dynamodb

func Get

func Get(eb expression.Builder, get dynamodb.Get, key Itemizer) *Reader

Get starts a read and adds one get operation

func NewReader added in v0.6.0

func NewReader() *Reader

NewReader inits an empty read

func (*Reader) Get added in v0.6.0

func (r *Reader) Get(eb expression.Builder, get dynamodb.Get, key Itemizer) *Reader

Get adds a get item to the read

func (*Reader) Run added in v0.6.0

func (r *Reader) Run(ctx context.Context, ddb Dynamo) (res Result, err error)

Run the read and return results

type Result

type Result interface {
	Err() error
	Len() int64
	Next() bool
	Scan(v interface {
		Itemizer
		Deitemizer
	}) error
}

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner holds a DynamoDB query

func Scan

func Scan(b expression.Builder, in dynamodb.ScanInput) (q *Scanner)

Scan sets up a scanner that can be run to fetch

func (*Scanner) Run

func (q *Scanner) Run(ctx context.Context, ddb Dynamo) (r Result, err error)

Run will return a Query result for iteration

type Writer added in v0.6.0

type Writer struct {
	// contains filtered or unexported fields
}

Writer represents one or more DynamoDB write operations

func Check

Check will setup a write with the check

func Delete

func Delete(eb expression.Builder, o dynamodb.Delete, key Itemizer) *Writer

Delete will setup a write with the delete

func NewWriter added in v0.6.0

func NewWriter() *Writer

NewWriter inits a new write

func Put

func Put(eb expression.Builder, o dynamodb.Put, item Itemizer) *Writer

Put will setup a put with the check

func Update

func Update(eb expression.Builder, o dynamodb.Update, key Itemizer) *Writer

Update will setup a write with the update

func (*Writer) Check added in v0.6.0

func (tx *Writer) Check(eb expression.Builder, chk dynamodb.ConditionCheck, key Itemizer) *Writer

Check will add a check operation to the write

func (*Writer) Delete added in v0.6.0

func (tx *Writer) Delete(eb expression.Builder, del dynamodb.Delete, key Itemizer) *Writer

Update delete will add a Delete operation to the write

func (*Writer) Put added in v0.6.0

func (tx *Writer) Put(eb expression.Builder, put dynamodb.Put, item Itemizer) *Writer

Put will add a put operation to the write

func (*Writer) Run added in v0.6.0

func (tx *Writer) Run(ctx context.Context, ddb Dynamo) (r Result, err error)

Run the write

func (*Writer) Update added in v0.6.0

func (tx *Writer) Update(eb expression.Builder, upd dynamodb.Update, key Itemizer) *Writer

Update will add a update operation to the write

Jump to

Keyboard shortcuts

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