ddb

package
v0.0.0-...-8b292c0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

********************************************************************************** The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **********************************************************************************

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDynamoDBMissingConnectionString defines an error when a parameter set is
	// missing the DynamoDB connection string endpoint to connect to
	ErrDynamoDBMissingConnectionString = fmt.Errorf("missing DynamoDB connection string parameter")
	// ErrDynamoDBMissingAWSRegion defines an error when a parameter set is missing
	// the AWS Region the DynamoDB table exists in
	ErrDynamoDBMissingAWSRegion = fmt.Errorf("missing DynamoDB AWS region parameter")
	// ErrDynamoDBMissingTableParameter defines an error when a parameter set is
	// missing the DynamoDB table to execute operations against
	ErrDynamoDBMissingTableParameter = fmt.Errorf("missing DynamoDB table parameter")
)
View Source
var (
	// ErrInvalidDynamoDBKeyType represents an error condition when an invalid
	// DynamoDBKeyType value was not found
	ErrInvalidDynamoDBKeyType = fmt.Errorf("[%d] invalid DynamoDBKeyTYpe used", 2001)
)

Functions

This section is empty.

Types

type DynamoDB

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

DynamoDB is a struct that represents (and is a proxy for) a DynamoDB Table instance and implements the Database interface

func NewDynamoDB

func NewDynamoDB(cfg dataaccess.DataSourceConfiguration) (*DynamoDB, error)

NewDynamoDB creates a new DynamoDB struct and returns a pointer to the DynamoDB struct, otherwise an error is returned

func (*DynamoDB) DeleteBulk

func (dynamo *DynamoDB) DeleteBulk(documents []dataaccess.Document) (interface{}, error)

DeleteBulk removes/deletes the passed in slice of documkents from the datastore and returns the slice of deleted objects. Otherwise an error is returned.

func (*DynamoDB) DeleteItem

func (dynamo *DynamoDB) DeleteItem(attributename string, attributeValue interface{}) (interface{}, error)

DeleteItem removes/deletes the passed in document from the datastore and returns the deleted object. Otherwise an error is returned.

func (*DynamoDB) Exists

func (dynamo *DynamoDB) Exists(document dataaccess.Document) (bool, error)

Exists simply checks if a document exists in the configured index and returns a boolean indicating whether the doc exists. Otherwise an error is returned.

func (*DynamoDB) Get

func (dynamo *DynamoDB) Get(query dataaccess.Query) ([]dataaccess.Document, error)

Get retrieves all of the records that are contained in the query parameter

func (*DynamoDB) GetAll

func (dynamo *DynamoDB) GetAll() ([]dataaccess.Document, error)

GetAll retrieves all records from the given table, index, etc... Otherwise an error is returned.

func (*DynamoDB) GetItem

func (dynamo *DynamoDB) GetItem(attributeName string, attributeValue interface{}) (dataaccess.Document, error)

GetItem executes a query to return a single item based on the attribue name and value. Otherwise an error is returned.

func (*DynamoDB) GetList

func (dynamo *DynamoDB) GetList(attributeName string, attributeValue interface{}) ([]dataaccess.Document, error)

GetList executes a query to return a single item based on the attribue name and value. Otherwise an error is returned.

func (*DynamoDB) SaveBulk

func (dynamo *DynamoDB) SaveBulk(documents []dataaccess.Document) (interface{}, error)

SaveBulk saves the slice of documents passed and returns the list of document ids. Otherwise an error is returned.

func (*DynamoDB) SaveItem

func (dynamo *DynamoDB) SaveItem(document dataaccess.Document, allowUpdate bool) (interface{}, error)

SaveItem saves the passed in docuemnt and returns the object id. Otherwise an error is returned.

func (*DynamoDB) SetUnmarshalFn

func (dynamo *DynamoDB) SetUnmarshalFn(unmarshal dataaccess.UnmarshalFn)

SetUnmarshalFn sets the object specific logic to unmarshal the DynamoDB objects to their respective object respresentation

func (*DynamoDB) UpdateBulk

func (dynamo *DynamoDB) UpdateBulk(documents []dataaccess.Document) (interface{}, error)

UpdateBulk updates the slice of documents passed in and returns a slice of document ids. Otherwise an error is returned.

func (*DynamoDB) UpdateItem

func (dynamo *DynamoDB) UpdateItem(document dataaccess.Document, replace bool) (interface{}, error)

UpdateItem updates the existing document passed and returns the document id. Otherwise an error is returned.

type DynamoDBKeyType

type DynamoDBKeyType int

DynamoDBKeyType represents an Enum constant for the different types of DynamoDB key types

const (
	// HASH represents a DynamoDB hash key
	HASH DynamoDBKeyType = iota
	// RANGE represents a DynamoDB range key
	RANGE
	// NONE represents that the attached attribute is not a key attribute
	NONE
)

func DynamoDBKeyTypeFromString

func DynamoDBKeyTypeFromString(keyTypeString string) (keyType DynamoDBKeyType, err error)

DynamoDBKeyTypeFromString returns the DynamoDBKeyType from the keyTypeString representation

func (DynamoDBKeyType) String

func (keyType DynamoDBKeyType) String() string

String takes the curretn DynamoDBKeyType form the keyTypeString representation

type DynamoDBTableAttribute

type DynamoDBTableAttribute struct {
	Name          string          `json:"name" mapstructure:"name"`
	AttributeType string          `json:"attributetype" mapstructure:"attributetype"`
	KeyType       DynamoDBKeyType `json:"keytype" mapstructure:"keytype"`
}

DynamoDBTableAttribute holds all of the information that defines that attributes and keys for a DynamoDB table

func (DynamoDBTableAttribute) MarshalJSON

func (attribute DynamoDBTableAttribute) MarshalJSON() ([]byte, error)

MarshalJSON is a method implemented allowing serialization of the KeyType value

func (*DynamoDBTableAttribute) UnmarshalJSON

func (attribute *DynamoDBTableAttribute) UnmarshalJSON(data []byte) error

UnmarshalJSON is a method implemented allowing de-serialization of the KeyType value

type DynamoDBTableConfiguration

type DynamoDBTableConfiguration struct {
	TableCreateConfig DynamoDBTableCreateConfiguration `json:"tablecreateconfig" mapstructure:"tablecreateconfig"`
	Name              string                           `json:"name" yaml:"name" mapstructure:"name"`
	Create            bool                             `json:"create" yaml:"create" mapstructure:"create"`
}

DynamoDBTableConfiguration holds all of the information needed to define a table and provides the configuration parameters if the table does not exist

type DynamoDBTableCreateConfiguration

type DynamoDBTableCreateConfiguration struct {
	Attributes      []DynamoDBTableAttribute `json:"attributes" mapstructure:"attributes"`
	ReadThroughput  int64                    `json:"readthroughput" mapstructure:"readthroughput"`
	WriteThroughput int64                    `json:"writethroughput" mapstructure:"writethroughput"`
}

DynamoDBTableCreateConfiguration holds all o fthe information needed to define the table creation values

Directories

Path Synopsis
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
********************************************************************************** The MIT License (MIT) Copyright (c) 2022 Sean Beard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Jump to

Keyboard shortcuts

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