Documentation ¶
Overview ¶
Package dynamo offers a rich DynamoDB client.
Index ¶
- Constants
- Variables
- func Marshal(v interface{}) (*dynamodb.AttributeValue, error)
- func MarshalItem(v interface{}) (map[string]*dynamodb.AttributeValue, error)
- func Unmarshal(av *dynamodb.AttributeValue, out interface{}) error
- func UnmarshalItem(item map[string]*dynamodb.AttributeValue, out interface{}) error
- type Batch
- type BatchGet
- func (bg *BatchGet) All(out interface{}) error
- func (bg *BatchGet) AllWithContext(ctx aws.Context, out interface{}) error
- func (bg *BatchGet) And(keys ...Keyed) *BatchGet
- func (bg *BatchGet) Consistent(on bool) *BatchGet
- func (bg *BatchGet) ConsumedCapacity(cc *ConsumedCapacity) *BatchGet
- func (bg *BatchGet) Iter() Iter
- type BatchWrite
- func (bw *BatchWrite) ConsumedCapacity(cc *ConsumedCapacity) *BatchWrite
- func (bw *BatchWrite) Delete(keys ...Keyed) *BatchWrite
- func (bw *BatchWrite) Put(items ...interface{}) *BatchWrite
- func (bw *BatchWrite) Run() (wrote int, err error)
- func (bw *BatchWrite) RunWithContext(ctx aws.Context) (wrote int, err error)
- type Coder
- type ConsumedCapacity
- type CreateTable
- func (ct *CreateTable) Index(index Index) *CreateTable
- func (ct *CreateTable) Project(index string, projection IndexProjection, includeAttribs ...string) *CreateTable
- func (ct *CreateTable) Provision(readUnits, writeUnits int64) *CreateTable
- func (ct *CreateTable) ProvisionIndex(index string, readUnits, writeUnits int64) *CreateTable
- func (ct *CreateTable) Run() error
- func (ct *CreateTable) RunWithContext(ctx aws.Context) error
- func (ct *CreateTable) Stream(view StreamView) *CreateTable
- type DB
- type Delete
- func (d *Delete) ConsumedCapacity(cc *ConsumedCapacity) *Delete
- func (d *Delete) DeleteInput() *dynamodb.DeleteItemInput
- func (d *Delete) If(expr string, args ...interface{}) *Delete
- func (d *Delete) OldValue(out interface{}) error
- func (d *Delete) OldValueWithContext(ctx aws.Context, out interface{}) error
- func (d *Delete) Range(name string, value interface{}) *Delete
- func (d *Delete) Run() error
- func (d *Delete) RunWithContext(ctx aws.Context) error
- type DeleteTable
- type DescribeTable
- type Description
- type Index
- type IndexProjection
- type Iter
- type KeyType
- type Keyed
- type Keys
- type ListTables
- type Marshaler
- type Operator
- type Order
- type PagingIter
- type PagingKey
- type Put
- func (p *Put) ConsumedCapacity(cc *ConsumedCapacity) *Put
- func (p *Put) If(expr string, args ...interface{}) *Put
- func (p *Put) Input() *dynamodb.PutItemInput
- func (p *Put) OldValue(out interface{}) error
- func (p *Put) OldValueWithContext(ctx aws.Context, out interface{}) error
- func (p *Put) Run() error
- func (p *Put) RunWithContext(ctx aws.Context) error
- type Query
- func (q *Query) All(out interface{}) error
- func (q *Query) AllWithContext(ctx aws.Context, out interface{}) error
- func (q *Query) AllWithLastEvaluatedKey(out interface{}) (PagingKey, error)
- func (q *Query) AllWithLastEvaluatedKeyContext(ctx aws.Context, out interface{}) (PagingKey, error)
- func (q *Query) Consistent(on bool) *Query
- func (q *Query) ConsumedCapacity(cc *ConsumedCapacity) *Query
- func (q *Query) Count() (int64, error)
- func (q *Query) CountWithContext(ctx aws.Context) (int64, error)
- func (q *Query) Filter(expr string, args ...interface{}) *Query
- func (q *Query) Index(name string) *Query
- func (q *Query) Iter() PagingIter
- func (q *Query) Limit(limit int64) *Query
- func (q *Query) One(out interface{}) error
- func (q *Query) OneWithContext(ctx aws.Context, out interface{}) error
- func (q *Query) Order(order Order) *Query
- func (q *Query) Project(paths ...string) *Query
- func (q *Query) ProjectExpr(expr string, args ...interface{}) *Query
- func (q *Query) Range(name string, op Operator, values ...interface{}) *Query
- func (q *Query) SearchLimit(limit int64) *Query
- func (q *Query) StartFrom(key PagingKey) *Query
- type Scan
- func (s *Scan) All(out interface{}) error
- func (s *Scan) AllWithContext(ctx aws.Context, out interface{}) error
- func (s *Scan) AllWithLastEvaluatedKey(out interface{}) (PagingKey, error)
- func (s *Scan) AllWithLastEvaluatedKeyContext(ctx aws.Context, out interface{}) (PagingKey, error)
- func (s *Scan) Consistent(on bool) *Scan
- func (s *Scan) ConsumedCapacity(cc *ConsumedCapacity) *Scan
- func (s *Scan) Filter(expr string, args ...interface{}) *Scan
- func (s *Scan) Index(name string) *Scan
- func (s *Scan) Iter() PagingIter
- func (s *Scan) Limit(limit int64) *Scan
- func (s *Scan) Project(paths ...string) *Scan
- func (s *Scan) SearchLimit(limit int64) *Scan
- func (s *Scan) StartFrom(key PagingKey) *Scan
- type Status
- type StreamView
- type Table
- func (table Table) Batch(hashAndRangeKeyName ...string) Batch
- func (table Table) Delete(name string, value interface{}) *Delete
- func (table Table) DeleteTable() *DeleteTable
- func (table Table) Describe() *DescribeTable
- func (table Table) Get(name string, value interface{}) *Query
- func (table Table) Name() string
- func (table Table) Put(item interface{}) *Put
- func (table Table) Scan() *Scan
- func (table Table) Update(hashKey string, value interface{}) *Update
- func (table Table) UpdateTable() *UpdateTable
- type Throughput
- type Unmarshaler
- type Update
- func (u *Update) Add(path string, value interface{}) *Update
- func (u *Update) AddFloatsToSet(path string, values ...float64) *Update
- func (u *Update) AddIntsToSet(path string, values ...int) *Update
- func (u *Update) AddStringsToSet(path string, values ...string) *Update
- func (u *Update) Append(path string, value interface{}) *Update
- func (u *Update) ConsumedCapacity(cc *ConsumedCapacity) *Update
- func (u *Update) DeleteFloatsFromSet(path string, values ...float64) *Update
- func (u *Update) DeleteIntsFromSet(path string, values ...int) *Update
- func (u *Update) DeleteStringsFromSet(path string, values ...string) *Update
- func (u *Update) If(expr string, args ...interface{}) *Update
- func (u *Update) OldValue(out interface{}) error
- func (u *Update) OldValueWithContext(ctx aws.Context, out interface{}) error
- func (u *Update) Prepend(path string, value interface{}) *Update
- func (u *Update) Range(name string, value interface{}) *Update
- func (u *Update) Remove(paths ...string) *Update
- func (u *Update) RemoveExpr(expr string, args ...interface{}) *Update
- func (u *Update) Run() error
- func (u *Update) RunWithContext(ctx aws.Context) error
- func (u *Update) Set(path string, value interface{}) *Update
- func (u *Update) SetExpr(expr string, args ...interface{}) *Update
- func (u *Update) SetIfNotExists(path string, value interface{}) *Update
- func (u *Update) SetSet(path string, value interface{}) *Update
- func (u *Update) Value(out interface{}) error
- func (u *Update) ValueWithContext(ctx aws.Context, out interface{}) error
- type UpdateTable
- func (ut *UpdateTable) CreateIndex(index Index) *UpdateTable
- func (ut *UpdateTable) DeleteIndex(name string) *UpdateTable
- func (ut *UpdateTable) DisableStream() *UpdateTable
- func (ut *UpdateTable) Provision(read, write int64) *UpdateTable
- func (ut *UpdateTable) ProvisionIndex(name string, read, write int64) *UpdateTable
- func (ut *UpdateTable) Run() (Description, error)
- func (ut *UpdateTable) RunWithContext(ctx aws.Context) (Description, error)
- func (ut *UpdateTable) Stream(view StreamView) *UpdateTable
Constants ¶
const ( BinaryType KeyType = "B" StringType = "S" NumberType = "N" NoneType = "" )
Key types for table and index hash/range keys.
const ( Equal Operator = "EQ" NotEqual = "NE" Less = "LT" LessOrEqual = "LE" Greater = "GT" GreaterOrEqual = "GE" BeginsWith = "BEGINS_WITH" Between = "BETWEEN" )
Operators used for comparing against the range key in queries.
const ( // The table or index is ready for use. ActiveStatus Status = "ACTIVE" // The table or index is being created. CreatingStatus = "CREATING" // The table or index is being updated. UpdatingStatus = "UPDATING" // The table or index is being deleted. DeletingStatus = "DELETING" )
Variables ¶
var ( // ErrNotFound is returned when no items could be found in Get or OldValue a and similar operations. ErrNotFound = errors.New("dynamo: no item found") // ErrTooMany is returned when one item was requested, but the query returned multiple items. ErrTooMany = errors.New("dynamo: too many items") )
var RetryTimeout = 1 * time.Minute
RetryTimeout defines the maximum amount of time that requests will attempt to automatically retry for. In other words, this is the maximum amount of time that dynamo operations will block. RetryTimeout is only considered by methods that do not take a context. Higher values are better when using tables with lower throughput.
Functions ¶
func Marshal ¶
func Marshal(v interface{}) (*dynamodb.AttributeValue, error)
Marshal converts the given value into a DynamoDB attribute value.
func MarshalItem ¶
func MarshalItem(v interface{}) (map[string]*dynamodb.AttributeValue, error)
MarshalItem converts the given struct into a DynamoDB item.
func Unmarshal ¶
func Unmarshal(av *dynamodb.AttributeValue, out interface{}) error
Unmarshal decodes a DynamoDB value into out, which must be a pointer.
func UnmarshalItem ¶
func UnmarshalItem(item map[string]*dynamodb.AttributeValue, out interface{}) error
Unmarshal decodes a DynamoDB item into out, which must be a pointer.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch stores the names of the hash key and range key for creating new batches.
func (Batch) Get ¶
Get creates a new batch get item request with the given keys.
table.Batch("ID", "Month"). Get([]dynamo.Keys{{1, "2015-10"}, {42, "2015-12"}, {42, "1992-02"}}...). All(&results)
func (Batch) Write ¶
func (b Batch) Write() *BatchWrite
Write creates a new batch write request, to which puts and deletes can be added.
type BatchGet ¶
type BatchGet struct {
// contains filtered or unexported fields
}
BatchGet is a BatchGetItem operation.
func (*BatchGet) All ¶
All executes this request and unmarshals all results to out, which must be a pointer to a slice.
func (*BatchGet) AllWithContext ¶ added in v1.0.1
AllWithContext executes this request and unmarshals all results to out, which must be a pointer to a slice.
func (*BatchGet) Consistent ¶
Consistent will, if on is true, make this batch use a strongly consistent read. Reads are eventually consistent by default. Strongly consistent reads are more resource-heavy than eventually consistent reads.
func (*BatchGet) ConsumedCapacity ¶
func (bg *BatchGet) ConsumedCapacity(cc *ConsumedCapacity) *BatchGet
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
type BatchWrite ¶
type BatchWrite struct {
// contains filtered or unexported fields
}
BatchWrite is a BatchWriteItem operation.
func (*BatchWrite) ConsumedCapacity ¶
func (bw *BatchWrite) ConsumedCapacity(cc *ConsumedCapacity) *BatchWrite
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
func (*BatchWrite) Delete ¶
func (bw *BatchWrite) Delete(keys ...Keyed) *BatchWrite
Delete adds delete operations for the given keys to this batch.
func (*BatchWrite) Put ¶
func (bw *BatchWrite) Put(items ...interface{}) *BatchWrite
Put adds put operations for items to this batch.
func (*BatchWrite) Run ¶
func (bw *BatchWrite) Run() (wrote int, err error)
Run executes this batch. For batches with more than 25 operations, an error could indicate that some records have been written and some have not. Consult the wrote return amount to figure out which operations have succeeded.
func (*BatchWrite) RunWithContext ¶
func (bw *BatchWrite) RunWithContext(ctx aws.Context) (wrote int, err error)
type Coder ¶
type Coder interface { Marshaler Unmarshaler }
func AWSEncoding ¶
func AWSEncoding(v interface{}) Coder
AWSEncoding wraps an object, forcing it to use AWS's official dynamodbattribute package for encoding and decoding. This allows you to use the "dynamodbav" struct tags. When decoding, v must be a pointer.
type ConsumedCapacity ¶
type ConsumedCapacity struct { // Total is the total number of capacity units consumed during this operation. Total float64 // GSI is a map of Global Secondary Index names to consumed capacity units. GSI map[string]float64 // GSI is a map of Local Secondary Index names to consumed capacity units. LSI map[string]float64 // Table is the amount of throughput consumed by the table. Table float64 // TableName is the name of the table affected by this operation. TableName string }
ConsumedCapacity represents the amount of throughput capacity consumed during an operation.
type CreateTable ¶
type CreateTable struct {
// contains filtered or unexported fields
}
CreateTable is a request to create a new table. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html
func (*CreateTable) Index ¶
func (ct *CreateTable) Index(index Index) *CreateTable
Index specifies an index to add to this table.
func (*CreateTable) Project ¶
func (ct *CreateTable) Project(index string, projection IndexProjection, includeAttribs ...string) *CreateTable
Project specifies the projection type for the given table. When using IncludeProjection, you must specify the additional attributes to include via includeAttribs.
func (*CreateTable) Provision ¶
func (ct *CreateTable) Provision(readUnits, writeUnits int64) *CreateTable
Provision specifies the provisioned read and write capacity for this table. If Provision isn't called, the table will be created with 1 unit each.
func (*CreateTable) ProvisionIndex ¶
func (ct *CreateTable) ProvisionIndex(index string, readUnits, writeUnits int64) *CreateTable
ProvisionIndex specifies the provisioned read and write capacity for the given global secondary index. Local secondary indices share their capacity with the table.
func (*CreateTable) Run ¶
func (ct *CreateTable) Run() error
Run creates this table or returns and error.
func (*CreateTable) RunWithContext ¶
func (ct *CreateTable) RunWithContext(ctx aws.Context) error
func (*CreateTable) Stream ¶
func (ct *CreateTable) Stream(view StreamView) *CreateTable
Stream enables DynamoDB Streams for this table which the specified type of view. Streams are disabled by default.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a DynamoDB client.
func New ¶
func New(p client.ConfigProvider, cfgs ...*aws.Config) *DB
New creates a new client with the given configuration.
func NewFromIface ¶
func NewFromIface(client dynamodbiface.DynamoDBAPI) *DB
NewFromIface creates a new client with the given interface.
func (*DB) Client ¶
func (db *DB) Client() dynamodbiface.DynamoDBAPI
Client returns this DB's internal client used to make API requests.
func (*DB) CreateTable ¶
func (db *DB) CreateTable(name string, from interface{}) *CreateTable
CreateTable begins a new operation to create a table with the given name. The second parameter must be a struct with appropriate hash and range key struct tags for the primary key and all indices.
An example of a from struct follows:
type UserAction struct { UserID string `dynamo:"ID,hash" index:"Seq-ID-index,range"` Time time.Time `dynamo:",range"` Seq int64 `localIndex:"ID-Seq-index,range" index:"Seq-ID-index,hash"` UUID string `index:"UUID-index,hash"` }
This creates a table with the primary hash key ID and range key Time. It creates two global secondary indices called UUID-index and Seq-ID-index, and a local secondary index called ID-Seq-index.
func (*DB) ListTables ¶
func (db *DB) ListTables() *ListTables
ListTables begins a new request to list all tables.
type Delete ¶
type Delete struct {
// contains filtered or unexported fields
}
Delete is a request to delete an item. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html
func (*Delete) ConsumedCapacity ¶
func (d *Delete) ConsumedCapacity(cc *ConsumedCapacity) *Delete
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
func (*Delete) DeleteInput ¶ added in v1.0.2
func (d *Delete) DeleteInput() *dynamodb.DeleteItemInput
func (*Delete) If ¶
If specifies a conditional expression for this delete to succeed. Use single quotes to specificy reserved names inline (like 'Count'). Use the placeholder ? within the expression to substitute values, and use $ for names. You need to use quoted or placeholder names when the name is a reserved word in DynamoDB.
func (*Delete) OldValue ¶
OldValue executes this delete request, unmarshaling the previous value to out. Returns ErrNotFound is there was no previous value.
func (*Delete) OldValueWithContext ¶
type DeleteTable ¶
type DeleteTable struct {
// contains filtered or unexported fields
}
DeleteTable is a request to delete a table. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html
func (*DeleteTable) Run ¶
func (dt *DeleteTable) Run() error
Run executes this request and deletes the table.
func (*DeleteTable) RunWithContext ¶
func (dt *DeleteTable) RunWithContext(ctx aws.Context) error
RunWithContext executes this request and deletes the table.
type DescribeTable ¶
type DescribeTable struct {
// contains filtered or unexported fields
}
DescribeTable is a request for information about a table and its indexes. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html
func (*DescribeTable) Run ¶
func (dt *DescribeTable) Run() (Description, error)
Run executes this request and describe the table.
func (*DescribeTable) RunWithContext ¶
func (dt *DescribeTable) RunWithContext(ctx aws.Context) (Description, error)
type Description ¶
type Description struct { Name string ARN string Status Status Created time.Time // Attribute name of the hash key (a.k.a. partition key). HashKey string HashKeyType KeyType // Attribute name of the range key (a.k.a. sort key) or blank if nonexistant. RangeKey string RangeKeyType KeyType // Provisioned throughput for this table. Throughput Throughput // The number of items of the table, updated every 6 hours. Items int64 // The size of this table in bytes, updated every 6 hours. Size int64 // Global secondary indexes. GSI []Index // Local secondary indexes. LSI []Index StreamEnabled bool StreamView StreamView LatestStreamARN string LatestStreamLabel string }
Description contains information about a table.
func (Description) Active ¶
func (d Description) Active() bool
type Index ¶
type Index struct { Name string ARN string Status Status Backfilling bool // only for GSI // Local is true when this index is a local secondary index, otherwise it is a global secondary index. Local bool // Attribute name of the hash key (a.k.a. partition key). HashKey string HashKeyType KeyType // Attribute name of the range key (a.k.a. sort key) or blank if nonexistant. RangeKey string RangeKeyType KeyType // The provisioned throughput for this index. Throughput Throughput Items int64 Size int64 ProjectionType IndexProjection // Non-key attributes for this index's projection (if ProjectionType is IncludeProjection). ProjectionAttribs []string }
type IndexProjection ¶
type IndexProjection string
IndexProjection determines which attributes are mirrored into indices.
var ( // Only the key attributes of the modified item are written to the stream. KeysOnlyProjection IndexProjection = dynamodb.ProjectionTypeKeysOnly // All of the table attributes are projected into the index. AllProjection IndexProjection = dynamodb.ProjectionTypeAll // Only the specified table attributes are projected into the index. IncludeProjection IndexProjection = dynamodb.ProjectionTypeInclude )
type Iter ¶
type Iter interface { // Next tries to unmarshal the next result into out. // Returns false when it is complete or if it runs into an error. Next(out interface{}) bool // NextWithContext tries to unmarshal the next result into out. // Returns false when it is complete or if it runs into an error. NextWithContext(ctx aws.Context, out interface{}) bool // Err returns the error encountered, if any. // You should check this after Next is finished. Err() error }
Iter is an iterator for request results.
type KeyType ¶
type KeyType string
KeyType is used to specify the type of hash and range keys for tables and indexes.
type Keyed ¶
type Keyed interface { HashKey() interface{} RangeKey() interface{} }
Keyed provides hash key and range key values.
type Keys ¶
type Keys [2]interface{}
Keys provides an easy way to specify the hash and range keys.
table.Batch("ID", "Month"). Get([]dynamo.Keys{{1, "2015-10"}, {42, "2015-12"}, {42, "1992-02"}}...). All(&results)
type ListTables ¶
type ListTables struct {
// contains filtered or unexported fields
}
ListTables is a request to list tables. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html
func (*ListTables) All ¶
func (lt *ListTables) All() ([]string, error)
All returns every table or an error.
func (*ListTables) AllWithContext ¶
func (lt *ListTables) AllWithContext(ctx aws.Context) ([]string, error)
AllWithContext returns every table or an error.
func (*ListTables) Iter ¶
func (lt *ListTables) Iter() Iter
Iter returns an iterator of table names. This iterator's Next functions will only accept type *string as their out parameter.
type Marshaler ¶
type Marshaler interface {
MarshalDynamo() (*dynamodb.AttributeValue, error)
}
Marshaler is the interface implemented by objects that can marshal themselves into an AttributeValue.
type PagingIter ¶
type PagingIter interface { Iter // LastEvaluatedKey returns a key that can be passed to StartFrom in Query or Scan. // Combined with SearchLimit, it is useful for paginating partial results. LastEvaluatedKey() PagingKey }
PagingIter is an iterator of request results that can also return a key used for splitting results.
type PagingKey ¶
type PagingKey map[string]*dynamodb.AttributeValue
PagingKey is a key used for splitting up partial results. Get a PagingKey from a PagingIter and pass it to StartFrom in Query or Scan.
type Put ¶
type Put struct {
// contains filtered or unexported fields
}
Put is a request to create or replace an item. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
func (*Put) ConsumedCapacity ¶
func (p *Put) ConsumedCapacity(cc *ConsumedCapacity) *Put
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
func (*Put) If ¶
If specifies a conditional expression for this put to succeed. Use single quotes to specificy reserved names inline (like 'Count'). Use the placeholder ? within the expression to substitute values, and use $ for names. You need to use quoted or placeholder names when the name is a reserved word in DynamoDB.
func (*Put) Input ¶ added in v1.0.1
func (p *Put) Input() *dynamodb.PutItemInput
func (*Put) OldValue ¶
OldValue executes this put, unmarshaling the previous value into out. Returns ErrNotFound is there was no previous value.
func (*Put) OldValueWithContext ¶
OldValue executes this put, unmarshaling the previous value into out. Returns ErrNotFound is there was no previous value.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a request to get one or more items in a table. Query uses the DynamoDB query for requests for multiple items, and GetItem for one. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html and http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
func (*Query) All ¶
All executes this request and unmarshals all results to out, which must be a pointer to a slice.
func (*Query) AllWithContext ¶
func (*Query) AllWithLastEvaluatedKey ¶
AllWithLastEvaluatedKey executes this request and unmarshals all results to out, which must be a pointer to a slice. This returns a PagingKey you can use with StartFrom to split up results.
func (*Query) AllWithLastEvaluatedKeyContext ¶
func (*Query) Consistent ¶
Consistent will, if on is true, make this query a strongly consistent read. Queries are eventually consistent by default. Strongly consistent reads are more resource-heavy than eventually consistent reads.
func (*Query) ConsumedCapacity ¶
func (q *Query) ConsumedCapacity(cc *ConsumedCapacity) *Query
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
func (*Query) Filter ¶
Filter takes an expression that all results will be evaluated against. Use single quotes to specificy reserved names inline (like 'Count'). Use the placeholder ? within the expression to substitute values, and use $ for names. You need to use quoted or placeholder names when the name is a reserved word in DynamoDB. Multiple calls to Filter will be combined with AND.
func (*Query) Iter ¶
func (q *Query) Iter() PagingIter
Iter returns a results iterator for this request.
func (*Query) One ¶
One executes this query and retrieves a single result, unmarshaling the result to out.
func (*Query) OneWithContext ¶
func (*Query) Order ¶
Order specifies the desired result order. Requires a range key (a.k.a. partition key) to be specified.
func (*Query) ProjectExpr ¶
ProjectExpr limits the result attributes to the given expression. Use single quotes to specificy reserved names inline (like 'Count'). Use the placeholder ? within the expression to substitute values, and use $ for names. You need to use quoted or placeholder names when the name is a reserved word in DynamoDB.
func (*Query) Range ¶
Range specifies the range key (a.k.a. sort key) or keys to get. For single item requests using One, op must be Equal. Name is the name of the range key. Op specifies the operator to use when comparing values.
func (*Query) SearchLimit ¶
SearchLimit specifies the maximum amount of results to examine. If a filter is not specified, the number of results will be limited. If a filter is specified, the number of results to consider for filtering will be limited.
type Scan ¶
type Scan struct {
// contains filtered or unexported fields
}
Scan is a request to scan all the data in a table. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html
func (*Scan) All ¶
All executes this request and unmarshals all results to out, which must be a pointer to a slice.
func (*Scan) AllWithContext ¶
AllWithContext executes this request and unmarshals all results to out, which must be a pointer to a slice.
func (*Scan) AllWithLastEvaluatedKey ¶
AllWithLastEvaluatedKey executes this request and unmarshals all results to out, which must be a pointer to a slice. It returns a key you can use with StartWith to continue this query.
func (*Scan) AllWithLastEvaluatedKeyContext ¶
AllWithLastEvaluatedKeyContext executes this request and unmarshals all results to out, which must be a pointer to a slice. It returns a key you can use with StartWith to continue this query.
func (*Scan) Consistent ¶
Consistent will, if on is true, make this scan use a strongly consistent read. Scans are eventually consistent by default. Strongly consistent reads are more resource-heavy than eventually consistent reads.
func (*Scan) ConsumedCapacity ¶
func (s *Scan) ConsumedCapacity(cc *ConsumedCapacity) *Scan
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
func (*Scan) Filter ¶
Filter takes an expression that all results will be evaluated against. Use single quotes to specificy reserved names inline (like 'Count'). Use the placeholder ? within the expression to substitute values, and use $ for names. You need to use quoted or placeholder names when the name is a reserved word in DynamoDB. Multiple calls to Filter will be combined with AND.
func (*Scan) Iter ¶
func (s *Scan) Iter() PagingIter
Iter returns a results iterator for this request.
func (*Scan) SearchLimit ¶
SearchLimit specifies a maximum amount of results to evaluate. Use this along with StartFrom and Iter's LastEvaluatedKey to split up results. Note that DynamoDB limits result sets to 1MB.
type StreamView ¶
type StreamView string
StreamView determines what information is written to a table's stream.
var ( // Only the key attributes of the modified item are written to the stream. KeysOnlyView StreamView = dynamodb.StreamViewTypeKeysOnly // The entire item, as it appears after it was modified, is written to the stream. NewImageView StreamView = dynamodb.StreamViewTypeNewImage // The entire item, as it appeared before it was modified, is written to the stream. OldImageView StreamView = dynamodb.StreamViewTypeOldImage // Both the new and the old item images of the item are written to the stream. NewAndOldImagesView StreamView = dynamodb.StreamViewTypeNewAndOldImages )
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a DynamoDB table.
func (Table) Batch ¶
Batch creates a new batch with the given hash key name, and range key name if provided. For purely Put batches, neither is necessary.
func (Table) Delete ¶
Delete creates a new request to delete an item. Key is the name of the hash key (a.k.a. partition key). Value is the value of the hash key.
func (Table) DeleteTable ¶
func (table Table) DeleteTable() *DeleteTable
DeleteTable begins a new request to delete this table.
func (Table) Describe ¶
func (table Table) Describe() *DescribeTable
Describe begins a new request to describe this table.
func (Table) Get ¶
Get creates a new request to get an item. Name is the name of the hash key (a.k.a. partition key). Value is the value of the hash key.
func (Table) UpdateTable ¶
func (table Table) UpdateTable() *UpdateTable
UpdateTable makes changes to this table's settings.
type Throughput ¶
type Throughput struct { // Read capacity units. Read int64 // Write capacity units. Write int64 // Time at which throughput was last increased for this table. LastInc time.Time // Time at which throughput was last decreased for this table. LastDec time.Time // The number of throughput decreases in this UTC calendar day. DecsToday int64 }
type Unmarshaler ¶
type Unmarshaler interface {
UnmarshalDynamo(av *dynamodb.AttributeValue) error
}
Unmarshaler is the interface implemented by objects that can unmarshal an AttributeValue into themselves.
type Update ¶
type Update struct {
// contains filtered or unexported fields
}
Update represents changes to an existing item. It uses the UpdateItem API. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
func (*Update) Add ¶
Add adds value to path. Path can be a number or a set. If path represents a number, value is atomically added to the number. If path represents a set, value must be a slice, a map[*]struct{}, or map[*]bool. Path must be a top-level attribute.
func (*Update) AddFloatsToSet ¶
AddFloatsToSet adds the given values to the number set specified by path.
func (*Update) AddIntsToSet ¶
AddIntsToSet adds the given values to the number set specified by path.
func (*Update) AddStringsToSet ¶
AddStringsToSet adds the given values to the string set specified by path.
func (*Update) ConsumedCapacity ¶
func (u *Update) ConsumedCapacity(cc *ConsumedCapacity) *Update
ConsumedCapacity will measure the throughput capacity consumed by this operation and add it to cc.
func (*Update) DeleteFloatsFromSet ¶
DeleteFloatsFromSet deletes the given values from the number set specified by path.
func (*Update) DeleteIntsFromSet ¶
DeleteIntsFromSet deletes the given values from the number set specified by path.
func (*Update) DeleteStringsFromSet ¶
DeleteStringsFromSet deletes the given values from the string set specified by path.
func (*Update) If ¶
If specifies a conditional expression for this update to succeed. Use single quotes to specificy reserved names inline (like 'Count'). Use the placeholder ? within the expression to substitute values, and use $ for names. You need to use quoted or placeholder names when the name is a reserved word in DynamoDB.
func (*Update) OldValueWithContext ¶
func (*Update) RemoveExpr ¶
RemoveExpr performs a custom remove expression, substituting the args into expr as in filter expressions.
RemoveExpr("MyList[$]", 5)
func (*Update) Set ¶
Set changes path to the given value. Paths that are reserved words are automatically escaped. Use single quotes to escape complex values like 'User'.'Count'.
func (*Update) SetExpr ¶
SetExpr performs a custom set expression, substituting the args into expr as in filter expressions. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html#DDB-UpdateItem-request-UpdateExpression
SetExpr("MyMap.$.$ = ?", key1, key2, val) SetExpr("'Counter' = 'Counter' + ?", 1)
func (*Update) SetIfNotExists ¶
SetIfNotExists changes path to the given value, if it does not already exist.
func (*Update) SetSet ¶
SetSet changes a set at the given path to the given value. SetSet marshals value to a string set, number set, or binary set. If value is of zero length or nil, path will be removed instead. Paths that are reserved words are automatically escaped. Use single quotes to escape complex values like 'User'.'Count'.
type UpdateTable ¶
type UpdateTable struct {
// contains filtered or unexported fields
}
UpdateTable is a request to change a table's settings. See: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html
func (*UpdateTable) CreateIndex ¶
func (ut *UpdateTable) CreateIndex(index Index) *UpdateTable
CreateIndex adds a new secondary global index. You must specify the index name, keys, key types, projection, and throughput.
func (*UpdateTable) DeleteIndex ¶
func (ut *UpdateTable) DeleteIndex(name string) *UpdateTable
DeleteIndex deletes the specified index.
func (*UpdateTable) DisableStream ¶
func (ut *UpdateTable) DisableStream() *UpdateTable
DisableStream disables this table's stream.
func (*UpdateTable) Provision ¶
func (ut *UpdateTable) Provision(read, write int64) *UpdateTable
Provision sets this table's read and write throughput capacity.
func (*UpdateTable) ProvisionIndex ¶
func (ut *UpdateTable) ProvisionIndex(name string, read, write int64) *UpdateTable
ProvisionIndex updates a global secondary index's read and write throughput capacity.
func (*UpdateTable) Run ¶
func (ut *UpdateTable) Run() (Description, error)
Run executes this request and describes the table.
func (*UpdateTable) RunWithContext ¶
func (ut *UpdateTable) RunWithContext(ctx aws.Context) (Description, error)
func (*UpdateTable) Stream ¶
func (ut *UpdateTable) Stream(view StreamView) *UpdateTable
Stream enables streaming and sets the stream view type.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
exprs
Package exprs is the internal package for parsing DynamoDB "expressions", including condition expressions and filter expressions.
|
Package exprs is the internal package for parsing DynamoDB "expressions", including condition expressions and filter expressions. |