dynamodbfriend

package module
v0.0.0-...-169c8db Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 9 Imported by: 0

README

dynamodbfriend

A friendly set of high-level DynamoDB capabilities

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Base dynamodbiface.DynamoDBAPI
}

Client is a high-level client to DynamoDB. Client is a wrapper around a DynamoDB interface implementer, such as dynamodb.DynamoDB, that enables high-level functionality provided by this package.

func NewClient

func NewClient(dynamoDB dynamodbiface.DynamoDBAPI) *Client

NewClient creates a new Client instance from a regular DynamoDB client from the AWS SDK v1 for Go.

func (*Client) Table

func (client *Client) Table(tableName string) *Table

Table instantiates a new Table instance from a Client. This operation only sets metadata for subsequent requests and is guaranteed to succeed.

type ErrNoViableIndexes

type ErrNoViableIndexes struct {
	TableName string
	Expr      *QueryExpr
}

ErrNoViableIndexes is returned when no viable indexes are found to execute a query expression on a table.

func (ErrNoViableIndexes) Error

func (e ErrNoViableIndexes) Error() string

type ErrParsingComplete

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

ErrParsingComplete is returned by QueryParser.Next() when all query items have been returned or when max pagination has been reached.

func (ErrParsingComplete) Error

func (e ErrParsingComplete) Error() string

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger is an interface used by dynamodbfriend for all logging.

type QueryExpr

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

QueryExpr is a fully-formed query expression.

func (*QueryExpr) And

func (expr *QueryExpr) And(key string) *QueryExprKey

And extends a query with an additional query condition.

func (*QueryExpr) ConsistentRead

func (expr *QueryExpr) ConsistentRead(val bool) *QueryExpr

ConsistentRead sets the read consistency. NOTE: For read consistency to be set to true, the partition key must be used with an Equals condition expression. Additionally, the max pagination will be set to 1.

func (*QueryExpr) LimitPerPage

func (expr *QueryExpr) LimitPerPage(count int) *QueryExpr

LimitPerPage restricts the number of items evaluated per query page.

func (*QueryExpr) MaxPagination

func (expr *QueryExpr) MaxPagination(count int) *QueryExpr

MaxPagination restricts the number of paginated requests to make to DynamoDB. If the max pagination is reached and all items have been read, the iterator will return Done.

func (*QueryExpr) OrderAscending

func (expr *QueryExpr) OrderAscending(sortKey string) *QueryExpr

OrderAscending sets the order of items returned based on values associated with a sort key, starting with the lowest value.

func (*QueryExpr) OrderDescending

func (expr *QueryExpr) OrderDescending(sortKey string) *QueryExpr

OrderDescending sets the order of items returned based on values associated with a sort key, starting with the highest value.

func (*QueryExpr) Select

func (expr *QueryExpr) Select(attributes ...string) *QueryExpr

Select restricts the attributes returned by a query.

func (*QueryExpr) WithFilter

func (expr *QueryExpr) WithFilter(condition expression.ConditionBuilder) *QueryExpr

WithFilter applies an additional condition in addition to other filters on the query expression. This allows for filter conditions that are not otherwise supported by the query expression, such as OR conditions.

func (*QueryExpr) WithLogger

func (expr *QueryExpr) WithLogger(logger Logger) *QueryExpr

WithLogger sets a logger used to print logs about querying operations performed using this expression.

type QueryExprKey

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

QueryExprKey is a partially-formed query expression.

To make a fully-formed query expression, the key part must be followed by a conditional.

func NewQuery

func NewQuery(key string) *QueryExprKey

NewQuery begins a new query expression.

func (*QueryExprKey) BeginsWith

func (k *QueryExprKey) BeginsWith(prefix string) *QueryExpr

BeginsWith is a conditional expression where the value associated with a query key must begin with a specified prefix.

func (*QueryExprKey) Between

func (k *QueryExprKey) Between(lowval, highval interface{}) *QueryExpr

Between is a conditional expression where the value associated with a query key must be between lowval and highval.

func (*QueryExprKey) Equals

func (k *QueryExprKey) Equals(val interface{}) *QueryExpr

Equals is a conditional where the value associated with a query key must equal val.

func (*QueryExprKey) GreaterThan

func (k *QueryExprKey) GreaterThan(val interface{}) *QueryExpr

GreaterThan is a conditional expression where the value associated with a query key must be greater than val.

func (*QueryExprKey) GreaterThanEqual

func (k *QueryExprKey) GreaterThanEqual(val interface{}) *QueryExpr

GreaterThanEqual is a conditional expression where the value associated with a query key must be greater than or equal to val.

func (*QueryExprKey) LessThan

func (k *QueryExprKey) LessThan(val interface{}) *QueryExpr

LessThan is a conditional where the value associated with a query key must be less than val.

func (*QueryExprKey) LessThanEqual

func (k *QueryExprKey) LessThanEqual(val interface{}) *QueryExpr

LessThanEqual is a conditional expression where the value associated with a query key must be less than or equal to val.

type QueryParser

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

QueryParser is used for parsing query results. The query is executed lazily. The underlying query will only happen when new items are requested and all buffered items have already been consumed.

func (*QueryParser) Next

func (parser *QueryParser) Next(ctx context.Context, val interface{}) error

Next retrieves the next value returned by the query. The val must be a non-nil pointer. The underlying query will only execute when new items are requested and any buffered items have already been consumed.

type Table

type Table struct {
	Name string
	// contains filtered or unexported fields
}

Table represents a DynamoDB table. This type keeps the table name ready for all calls to the underlying DynamoDB client.

func (*Table) Put

func (table *Table) Put(ctx context.Context, item interface{}) error

Put puts an item into the table. The item should have all attributes to be included in the table item tagged with the "dynamodbav" struct tag.

func (*Table) Query

func (table *Table) Query(ctx context.Context, expr *QueryExpr) (*QueryParser, error)

Query returns a new QueryParser that may be used to retrieve query results.

Jump to

Keyboard shortcuts

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