datastore

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package datastore provides a repository implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fields added in v0.0.21

func Fields(args ...interface{}) []string

Fields gets all fields for datastore item(s)

func Item added in v0.0.21

func Item(in interface{}, transient ...interface{}) (map[string]interface{}, error)

Item converts a struct to a map using reflection variation of: https://play.golang.org/p/2Qi3thFf--

Types

type Context added in v0.0.9

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

Context is a data store transactions

func NewContext added in v0.0.9

func NewContext(ctx context.Context, repo *Repository) (*Context, error)

NewContext creates a new instance of the data store context

func (*Context) Add added in v0.0.9

func (ctx *Context) Add(collection string, data interface{}) error

Add adds item to the repository

func (*Context) Commit added in v0.0.9

func (ctx *Context) Commit() error

Commit a datastore transaction

func (*Context) Remove added in v0.0.9

func (ctx *Context) Remove(collection string, filter interface{}) (int, error)

Remove removes items from the repository matching criteria.

func (*Context) Rollback added in v0.0.12

func (ctx *Context) Rollback() error

Rollback a datastore transaction

func (*Context) Update added in v0.0.9

func (ctx *Context) Update(collection string, filter, data interface{}) (int, error)

Update updates items matching filters

type Repository added in v0.0.2

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

Repository is an instance of a postgres Database

func New added in v0.0.2

func New(client client.Client) (*Repository, error)

New creates a new postgres database

func (*Repository) Context added in v0.0.9

func (r *Repository) Context(ctx context.Context) (*Context, error)

Context creates a new data store context

func (*Repository) Procedure added in v0.0.18

func (r *Repository) Procedure(ctx context.Context, subroutines ...func(tx *Context) error) error

Procedure executes a series of subroutines and bails fast if any errors occur

func (*Repository) Query added in v0.0.2

func (r *Repository) Query() client.Query

Query gets a new query for searching the repository.

func (*Repository) Search added in v0.0.2

func (r *Repository) Search(ctx context.Context, query client.Query, dst interface{}) error

Search retrieves items from the repository matching criteria.

Directories

Path Synopsis
Package client provides resources for data persistence and retrieval.
Package client provides resources for data persistence and retrieval.
Package internal provides our internal API resources.
Package internal provides our internal API resources.
mock
Package mock provides a basic mock for testing the datastore.
Package mock provides a basic mock for testing the datastore.
Package postgres provides a store implementation using Postgres.
Package postgres provides a store implementation using Postgres.
integration
Package integration provides resources for doing integration testing.
Package integration provides resources for doing integration testing.

Jump to

Keyboard shortcuts

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