ddbb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCategoryType

func ExtractCategoryType(s string) string

ExtractCategoryType splits the gsi_2_sk for pictures (e.g. Galerie_t_Ferne) to get the first part

func FormCategoryResponse

func FormCategoryResponse(summaries []ExtCategory) (events.APIGatewayProxyResponse, error)

FormCategoryResponse is a helper function to create an APIGateway response

func FormResponse

func FormResponse(summaries []ExtPic) (events.APIGatewayProxyResponse, error)

FormResponse is a helper function to create an APIGateway response

if err is not null they somehow throw away the apigatewayproxyresponse object, including the eventual header, which might lead to CORS problems..

func PKQuery

func PKQuery(pkName string) *dynamodb.QueryInput

PKQuery is a helper function to only query the partition key

func SplitActiveCategory

func SplitActiveCategory(s string) (category string, active string)

SplitActiveCategory splits the gsi_1_pk for pictures (e.g. Ferne_t) in two strings so they can be returned seperately to the frontend

Types

type Category

type Category struct {
	UUID         string `json:"pk"`
	Category     string `json:"gsi_1_pk"`
	Type         string `json:"gsi_3_pk"`
	CategoryType string `json:"gsi_4_pk"`
}

Category holds all fields of a category db entry

func CategoryQueryDynamoDB

func CategoryQueryDynamoDB(ctx context.Context, qi *dynamodb.QueryInput, sess *session.Session) ([]Category, error)

CategoryQueryDynamoDB is a helper that takes a query input and returns a struct

func FormatCategory

func FormatCategory(ec ExtCategory) (c Category)

FormatCategory transforms the data from dynamodb to a format the frontend can handle

type ExtCategory

type ExtCategory struct {
	UUID         string `json:"uuid"`
	Category     string `json:"name"`
	CategoryType string `json:"type_name"`
}

ExtCategory holds all fields of a category db entry

func FormatExtCategory

func FormatExtCategory(categories []Category) []ExtCategory

FormatExtCategory transforms the data from dynamodb to a format the frontend can handle

type ExtPic

type ExtPic struct {
	UUID         string `json:"uuid"`
	Category     string `json:"category_name"`
	CategoryType string `json:"category_type_name"`
	Order        int    `json:"order"`
	FrontPage    string `json:"front_page"`
	Description  string `json:"description"`
	Title        string `json:"title"`
	URL          string `json:"url"`
	Active       string `json:"active"`
}

ExtPic is the format the frontend recieves and expects

func FormatExtPic

func FormatExtPic(pictures []Picture) []ExtPic

FormatExtPic transforms the data from dynamodb to a format the frontend can handle

type Picture

type Picture struct {
	UUID               string `json:"pk"`
	ActiveCategory     string `json:"gsi_1_pk"`
	Order              int    `json:"gsi_1_sk_2_pk"`
	ActiveCategoryType string `json:"gsi_2_sk"`
	Type               string `json:"gsi_3_pk"`
	FrontPage          string `json:"gsi_4_pk"`
	Description        string `json:"gsi_4_sk"`
	Title              string `json:"title"`
	URL                string `json:"url"`
}

Picture holds all fields of a picture db entry

func FormatPic

func FormatPic(ep ExtPic) Picture

FormatPic transforms the data from the frontend format to the dynamodb one

func QueryDynamoDB

func QueryDynamoDB(ctx context.Context, qi *dynamodb.QueryInput, sess *session.Session) ([]Picture, error)

QueryDynamoDB is a helper that takes a query input and returns a struct

Jump to

Keyboard shortcuts

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