mdynamodb

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound = errors.New("record not found")
	ErrQueryThanOne   = errors.New("query than one")
)

Functions

func Init

func Init(cfg aws.Config)

func NewItemDao

func NewItemDao(tableName string) *dynamodbItem

func NewTableDao

func NewTableDao(tableName string) *dynamodbTable

Types

type ReqBatchGetItem

type ReqBatchGetItem struct {
	RequestItems map[string]types.KeysAndAttributes
}
itemDao.ReqBatchGetItem = mdynamodb.ReqBatchGetItem{
	RequestItems: map[string]types.KeysAndAttributes{
		"User": {
			Keys: []map[string]types.AttributeValue{
				{
					"UserID": &types.AttributeValueMemberN{
						Value: "123",
					},
				},
			},
		},
	},
}

type ReqBatchWriteItem

type ReqBatchWriteItem struct {
	RequestItems map[string][]types.WriteRequest
}

type ReqDeleteItem

type ReqDeleteItem struct {
	Key                       map[string]types.AttributeValue
	ConditionExpression       *string
	ExpressionAttributeNames  map[string]string
	ExpressionAttributeValues map[string]types.AttributeValue
	ReturnValues              types.ReturnValue
}

Key: map[string]types.AttributeValue{"UserID": &types.AttributeValueMemberN{Value: "123"}},

type ReqGetItem

type ReqGetItem struct {
	Key            map[string]types.AttributeValue
	ConsistentRead *bool
}
dao.ReqGetItem = mdynamodb.ReqGetItem{
	Key: map[string]types.AttributeValue{
		"UserID": &types.AttributeValueMemberN{Value: cast.ToString(req.UserID)},
	},
}

type ReqPutItem

type ReqPutItem struct {
	ItemMap                   map[string]types.AttributeValue
	ConditionExpression       *string
	ExpressionAttributeNames  map[string]string
	ExpressionAttributeValues map[string]types.AttributeValue
}

ItemMap: map[string]types.AttributeValue{"UserID": &types.AttributeValueMemberN{Value: "123"}}, ConditionExpression: "attribute_not_exists(UserID)",

type ReqQueryInput added in v1.0.5

type ReqQueryInput struct {
	IndexName                 *string
	KeyConditionExpression    *string
	FilterExpression          *string
	ExpressionAttributeNames  map[string]string
	ExpressionAttributeValues map[string]types.AttributeValue
	ExclusiveStartKey         map[string]types.AttributeValue
	Limit                     *int32
	ScanIndexForward          *bool
	Select                    types.Select
}

type ReqTransactGetItems

type ReqTransactGetItems struct {
	TransactItems []types.TransactGetItem
}
transcatDao.ReqTransactGetItems = mdynamodb.ReqTransactGetItems{
	TransactItems: []types.TransactGetItem{
		{
			Get: &types.Get{
				Key:                  map[string]types.AttributeValue{"UserID": &types.AttributeValueMemberN{Value: "123"}},
				TableName:            aws.String("User"),
				ProjectionExpression: aws.String("UserID"),
			},
		},
	},
}

type ReqTransactWriteItems

type ReqTransactWriteItems struct {
	TransactItems      []types.TransactWriteItem
	ClientRequestToken *string
}

type ReqUpdateItem

type ReqUpdateItem struct {
	Key                       map[string]types.AttributeValue
	ConditionExpression       *string
	UpdateExpression          *string
	ExpressionAttributeNames  map[string]string
	ExpressionAttributeValues map[string]types.AttributeValue
	ReturnValues              types.ReturnValue
}

exp, err := expression.NewBuilder().

WithUpdate(expression.Set(expression.Name("LastLoginAt"),
	expression.Value(time.Now().Unix()))).
WithCondition(expression.AttributeExists(expression.Name("UserID"))).
Build()

Key: map[string]types.AttributeValue{"UserID": &types.AttributeValueMemberN{Value: "123"}}, UpdateExpression: exp.Update(), ExpressionAttributeNames: exp.Names(), ExpressionAttributeValues: exp.Values(), ConditionExpression: exp.Condition(),

type Transact

type Transact struct {
}

func NewTransactDao

func NewTransactDao() *Transact

func (*Transact) TransactGetItems

func (item *Transact) TransactGetItems(req ReqTransactGetItems) (*dynamodb.TransactGetItemsOutput, error)

func (*Transact) TransactWriteItems

func (item *Transact) TransactWriteItems(req ReqTransactWriteItems) (*dynamodb.TransactWriteItemsOutput, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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