db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DynamoDBClient *dynamodb.Client
	TableName      string
)

Functions

func DeleteCollection

func DeleteCollection(ctx context.Context, postcode string, council string, suburb string) error

DeleteCollection deletes an existing collection.

func DeleteDisposalMethod

func DeleteDisposalMethod(ctx context.Context, collectionID string, name string) error

DeleteDisposalMethod deletes an existing disposal method.

func DeleteMaterial

func DeleteMaterial(ctx context.Context, name string, disposalmethodID string) error

DeleteMaterial deletes an existing material.

func DeleteProduct

func DeleteProduct(ctx context.Context, barcode string) error

DeleteProduct deletes an existing product.

func Initialize

func Initialize(ctx context.Context, profile string, region string, tableName string) error

Types

type Collection

type Collection struct {
	Postcode    string    `json:"postcode" dynamodbav:"postcode"`
	Council     string    `json:"council" dynamodbav:"council"`
	Suburb      string    `json:"suburb" dynamodbav:"suburb"`
	State       string    `json:"state" dynamodbav:"state"`
	Description string    `json:"description" dynamodbav:"description"`
	CreatedAt   time.Time `json:"createdAt" dynamodbav:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt" dynamodbav:"updatedAt"`
}

func GetCollection

func GetCollection(ctx context.Context, postcode string, council string, suburb string) (*Collection, error)

GetCollection fetches an existing collection.

func GetCollections added in v0.2.0

func GetCollections(ctx context.Context, postcode string) ([]*Collection, error)

GetCollections fetches all the collections under the postcode parameter.

func (*Collection) Create

func (c *Collection) Create(ctx context.Context) error

Create creates a new collection.

func (*Collection) Update

func (c *Collection) Update(ctx context.Context) error

Update will update an existing collection.

type Component

type Component struct {
	Name      string   `json:"name"`
	Materials []string `json:"materials"`
}

type DisposalMethod

type DisposalMethod struct {
	CollectionID string    `json:"collectionId" dynamodbav:"collectionId"`
	Name         string    `json:"name" dynamodbav:"name"`
	Description  string    `json:"description" dynamodbav:"description"`
	CreatedAt    time.Time `json:"createdAt" dynamodbav:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt" dynamodbav:"updatedAt"`
}

func GetDisposalMethod

func GetDisposalMethod(ctx context.Context, collectionID string, name string) (*DisposalMethod, error)

GetDisposalMethod fetches an existing disposal method.

func (*DisposalMethod) Create

func (d *DisposalMethod) Create(ctx context.Context) error

Create creates a new disposal method.

func (*DisposalMethod) Update

func (d *DisposalMethod) Update(ctx context.Context) error

Update will update an existing disposal method.

type Material

type Material struct {
	Name             string    `json:"name" dynamodbav:"name"`
	DisposalMethodID string    `json:"disposalMethodId" dynamodbav:"disposalMethodId"`
	Description      string    `json:"description" dynamodbav:"description"`
	CreatedAt        time.Time `json:"createdAt" dynamodbav:"createdAt"`
	UpdatedAt        time.Time `json:"updatedAt" dynamodbav:"updatedAt"`
}

func GetMaterial

func GetMaterial(ctx context.Context, name string, disposalmethodID string) (*Material, error)

GetMaterial fetches an existing material.

func (*Material) Create

func (m *Material) Create(ctx context.Context) error

Create creates a new material.

func (*Material) Update

func (m *Material) Update(ctx context.Context) error

Update will update an existing material.

type Product

type Product struct {
	Barcode     string       `json:"barcode" dynamodbav:"barcode"`
	BrandName   string       `json:"brandName" dynamodbav:"brandName"`
	ProductName string       `json:"productName" dynamodbav:"productName"`
	Components  []*Component `json:"components" dynamodbav:"components"`
	CreatedAt   time.Time    `json:"createdAt" dynamodbav:"createdAt"`
	UpdatedAt   time.Time    `json:"updatedAt" dynamodbav:"updatedAt"`
}

func GetProduct

func GetProduct(ctx context.Context, barcode string) (*Product, error)

GetProduct fetches an existing product.

func (*Product) Create

func (p *Product) Create(ctx context.Context) error

Create creates a new product.

func (*Product) Update

func (p *Product) Update(ctx context.Context) error

Update will updated an existing product.

Jump to

Keyboard shortcuts

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