Documentation ¶
Index ¶
- Constants
- func BoolValue(v bool) *types.AttributeValueMemberBOOL
- func NumberValue(v int64) *types.AttributeValueMemberN
- func StringValue(v string) *types.AttributeValueMemberS
- type Attribute
- type AttributeRecord
- type Client
- func (t *Client) BatchDeleteItems(ctx context.Context, input []map[string]types.AttributeValue) []map[string]types.AttributeValue
- func (t *Client) BatchGetItems(ctx context.Context, input []AttributeRecord, out interface{}) (err error)
- func (t *Client) BatchWriteItems(ctx context.Context, input []map[string]types.AttributeValue) error
- func (t *Client) DeleteItem(ctx context.Context, pk string, sk string) error
- func (t *Client) GetDynamoDBClient() *dynamodb.Client
- func (t *Client) GetItem(ctx context.Context, pk Attribute, sk Attribute, out interface{}) (err error, found bool)
- func (t *Client) NewKeys(pk Attribute, sk Attribute) map[string]Attribute
- func (t *Client) PutItem(ctx context.Context, pk Attribute, sk Attribute, item interface{}) error
- func (t *Client) Query(ctx context.Context, condition string, values map[string]Attribute, ...) (cursor map[string]Attribute, err error)
- func (t *Client) TransactDeleteItems(ctx context.Context, inputs []*TransactDeleteItemsInput) error
- func (t *Client) TransactItems(ctx context.Context, input ...types.TransactWriteItem) error
- func (t *Client) TransactPutItems(ctx context.Context, inputs []*TransactPutItemsInput) error
- func (t *Client) WithDeleteItem(pk string, sk string) types.TransactWriteItem
- func (t *Client) WithPutItem(pk string, sk string, item interface{}) types.TransactWriteItem
- type ClientOptions
- type DynamoClient
- type EndpointResolver
- type Index
- type QueryAPI
- type QueryInput
- type QueryOptions
- type ReadAPI
- type TransactDeleteItemsInput
- type TransactPutItemsInput
- type TransactWriteItem
- type TransactionAPI
- type WriteAPI
Constants ¶
const ChunkSize = 25
Variables ¶
This section is empty.
Functions ¶
func BoolValue ¶
func BoolValue(v bool) *types.AttributeValueMemberBOOL
func NumberValue ¶
func NumberValue(v int64) *types.AttributeValueMemberN
func StringValue ¶
func StringValue(v string) *types.AttributeValueMemberS
Types ¶
type Attribute ¶
type Attribute = types.AttributeValue
type AttributeRecord ¶
type Client ¶
type Client struct { TableName string Keys map[string]string // contains filtered or unexported fields }
func NewClient ¶
func NewClient(ctx context.Context, opt ClientOptions) (*Client, error)
Create a new instance of DynamoTable. internally creates aws connection configuration for the db If DynamoTable.Endpoint is specified connects to the db at the given URL, or the default credential of the system is used To connect to AWS DynamoDB from a running pod or EC2 instance, use the default credentials without Endpoint option To connect to a local DynamoDB process, provider Endpoint
table, err := dynamite.NewDynamoTable(dynamite.ClientOptions{ TableName: "test", Endpoint: &dynamite.EndpointResolver{ EndpointURL: "http://localhost:" + port, AccessKeyID: "dummy", SecretAccessKey: "dummy", }, PartitionKeyName: "pk", SortKeyName: "sk", Region: "us-east-1", })
func (*Client) BatchDeleteItems ¶
func (t *Client) BatchDeleteItems(ctx context.Context, input []map[string]types.AttributeValue) []map[string]types.AttributeValue
* * Used to batch delete records from dynamodb * @param input slice of record want to put to DB * @return error
func (*Client) BatchGetItems ¶
func (t *Client) BatchGetItems(ctx context.Context, input []AttributeRecord, out interface{}) (err error)
func (*Client) BatchWriteItems ¶
func (*Client) DeleteItem ¶
* * Used to delete a db record from dynamodb given a partition key and sort key * @param pk the partition key of the record * @param sk the sort key of the record
- @return true if the record was deleted, false otherwise
func (*Client) GetDynamoDBClient ¶
func (*Client) GetItem ¶
func (t *Client) GetItem(ctx context.Context, pk Attribute, sk Attribute, out interface{}) (err error, found bool)
Used to get a db record from dynamodb given a partition key and sort key @param partitionKey the partition key of the record @param sortKey the sort key of the record @param result the result of the query written to given memory reference @return error, true if the record was found, false otherwise
func (*Client) NewKeys ¶
Generate DynamoDB item key map for the given value Name of the keys were registered during the NewDynamoTable call
func (*Client) PutItem ¶
* * Used to put and update a db record from dynamodb given a partition key and sort key * @param item the item put into the database
- @return true if the record was put, false otherwise
func (*Client) Query ¶
func (t *Client) Query( ctx context.Context, condition string, values map[string]Attribute, out interface{}, opts ...QueryOptions, ) (cursor map[string]Attribute, err error)
TODO: improve with generics and avoid the `out` argument
func (*Client) TransactDeleteItems ¶
func (t *Client) TransactDeleteItems(ctx context.Context, inputs []*TransactDeleteItemsInput) error
TODO: [low priority] The aggregate size of the items in the transaction cannot exceed 4 MB.
func (*Client) TransactItems ¶
func (*Client) TransactPutItems ¶
func (t *Client) TransactPutItems(ctx context.Context, inputs []*TransactPutItemsInput) error
TransactWriteItems is a synchronous and idempotent write operation that groups up to 100 write actions in a single all-or-nothing operation. These actions can target up to 100 distinct items in one or more DynamoDB tables within the same AWS account and in the same Region. The aggregate size of the items in the transaction cannot exceed 4 MB. The actions are completed atomically so that either all of them succeed or none of them succeeds.
func (*Client) WithDeleteItem ¶
func (t *Client) WithDeleteItem(pk string, sk string) types.TransactWriteItem
func (*Client) WithPutItem ¶
func (t *Client) WithPutItem(pk string, sk string, item interface{}) types.TransactWriteItem
type ClientOptions ¶
type DynamoClient ¶
type DynamoClient interface { ReadAPI WriteAPI QueryAPI TransactionAPI }
type EndpointResolver ¶
func (EndpointResolver) ResolveEndpoint ¶
type QueryAPI ¶
type QueryAPI interface { // Perform a DynamoDB query with the key condition expression in first argument. // // If key condition contains template params eg: pk = :pk for values, second argument should provide values Query(ctx context.Context, condition string, params map[string]Attribute, out interface{}, opts ...QueryOptions) (map[string]Attribute, error) }
type QueryInput ¶
type QueryInput = dynamodb.QueryInput
type QueryOptions ¶
type QueryOptions func(q *dynamodb.QueryInput)
Fuction Struct for providing option input prams
func SortByAsc ¶
func SortByAsc(v bool) QueryOptions
FIXME: WithDescOrder instead? SortByAsc(true) doesn't make sense as dynamodb sorts by asc (default)
func WithCursorKey ¶
func WithCursorKey(key map[string]Attribute) QueryOptions
func WithFields ¶
func WithFields(fields []string) QueryOptions
WithFields func to be passed as optional param function to select specfic fielld from the db enity
func WithFilter ¶
func WithFilter(filterCon string) QueryOptions
func WithIndex ¶
func WithIndex(i string) QueryOptions
func WithLimit ¶
func WithLimit(v int32) QueryOptions
type TransactPutItemsInput ¶
type TransactWriteItem ¶
type TransactWriteItem types.TransactWriteItem
type TransactionAPI ¶
type TransactionAPI interface { TransactPutItems(ctx context.Context, items []*TransactPutItemsInput) error TransactItems(ctx context.Context, input ...types.TransactWriteItem) error }