core

package module
v0.0.0-...-1ea783d Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(req IDRequest, repo Repository) error

Types

type IDRequest

type IDRequest struct {
	ID string `json:"id"`
}

type PutRequest

type PutRequest struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

type PutResponse

type PutResponse struct {
	Key string `json:"key"`
}

type Repository

type Repository interface {
	// This method is meant to initialize the connection between the Function and the database
	// an error should be returned if the connection fails.
	Init() error
	// This Method stores a given object which is never nil in the database.
	// The object returned should be identical to the one inserted but with an id assigned
	// to it by the database or using the implementation if the element is inserted for the first time.
	// However this method is also used to update the ToDoItems when they are marked as done. It therefore must be ensured
	// that an ID is only created if the element is new. This is the case if the ID of the input todo item is either nil or
	// has length 0. It is not required to use the same memory address
	// therefore a new instance of the ToDoItem Struct can be created with the same values as the given one.
	// It the insertion fails this method should return an error and the first parameter should be nil
	Put(*ToDoItem) (*ToDoItem, error)
	// This method attempts to retrieve a ToDoItem from the database based on the given ID
	// if there is an error for example if the id cannot be found or the database does not exists this
	// method should return an error and the first parameter should be nil.
	Get(string) (*ToDoItem, error)
	// This method returns a list of all ToDoItems currently stored in the database. If no entries are found the array MUST
	// be empty and only if a unexpected error occurs the method shuld return an error. Then the first parameter shuld be nil
	List() ([]ToDoItem, error)
	// This method attempts to delete a ToDoItem from the database based on the given ID
	// if there is an error for example if the id cannot be found or the database does not exists this
	// method should return an error and the first parameter should be nil.
	Delete(string) error
}

type ToDoItem

type ToDoItem struct {
	ID                 string `json:"ID"`
	Title              string `json:"title"`
	Description        string `json:"description"`
	InsertionTimestamp int64  `json:"insertion_timestamp"`
	DoneTimestamp      int64  `json:"done_timestamp"`
	Done               bool   `json:"done"`
}

func Done

func Done(req IDRequest, repo Repository) (*ToDoItem, error)

func Get

func Get(req IDRequest, repo Repository) (*ToDoItem, error)

func List

func List(repo Repository) ([]ToDoItem, error)

func Put

func Put(req PutRequest, repo Repository) (*ToDoItem, error)

Jump to

Keyboard shortcuts

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