ds

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

The ds pgk creates a simple wrapper around common Datastore functions to facilitate unit testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export added in v0.2.0

func Export(ctx context.Context, timeout int, project string, bucket string, kinds ...string) ([]byte, error)

Types

type Client

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

func (Client) Client added in v1.2.4

func (client Client) Client() *datastore.Client

func (Client) Create

func (client Client) Create(ctx context.Context, parent *datastore.Key, entity Entity) (*datastore.Key, error)

Create will create a single Entity and return a generated key

func (Client) CreateNamed added in v0.1.16

func (client Client) CreateNamed(ctx context.Context, name string, parent *datastore.Key, entity Entity) (*datastore.Key, error)

CreateNamed will create a single Entity using its name key and parent (if exists)

func (Client) Delete

func (client Client) Delete(ctx context.Context, kind string, id int64, parent *datastore.Key) error

Delete will delete a single Entity using its generated key and parent (if exists)

func (Client) DeleteNamed added in v0.1.16

func (client Client) DeleteNamed(ctx context.Context, kind string, name string, parent *datastore.Key) error

DeleteNamed will delete a single named Entity using its name key and parent (if exists)

func (Client) Get

func (client Client) Get(ctx context.Context, id int64, parent *datastore.Key, entity Entity) error

Get will get a single Entity using its generated key and parent (if exists)

func (Client) GetNamed added in v0.1.16

func (client Client) GetNamed(ctx context.Context, name string, parent *datastore.Key, entity Entity) error

GetNamed will get a single Entity using its name key and parent (if exists)

func (Client) QGet added in v0.1.7

func (client Client) QGet(ctx context.Context, kind string, property string, value string, entity Entity) (*datastore.Key, error)

QGet returns a single Entity using a property and value combination

func (Client) QueryParent added in v0.5.0

func (client Client) QueryParent(ctx context.Context, kind string, parent *datastore.Key, entitySlicePtr interface{}) ([]*datastore.Key, error)

QueryParent will get all Entities of a Kind with the same parent entitySlicePtr must be a pointer to a slice of structs e.g. &[]struct{} returns a slice of keys which relate to the returned entities

func (Client) Update added in v0.4.0

func (client Client) Update(ctx context.Context, parent *datastore.Key, id int64, entity Entity) (*datastore.Key, error)

Update will update a single Entity using its generated key and parent (if exists)

type DatastoreClient

type DatastoreClient interface {
	Client() *datastore.Client
	Create(ctx context.Context, parent *datastore.Key, entity Entity) (*datastore.Key, error)
	Update(ctx context.Context, parent *datastore.Key, id int64, entity Entity) (*datastore.Key, error)
	Get(ctx context.Context, id int64, parent *datastore.Key, entity Entity) error
	Delete(ctx context.Context, kind string, id int64, parent *datastore.Key) error
	CreateNamed(ctx context.Context, name string, parent *datastore.Key, entity Entity) (*datastore.Key, error)
	GetNamed(ctx context.Context, name string, parent *datastore.Key, entity Entity) error
	DeleteNamed(ctx context.Context, kind string, name string, parent *datastore.Key) error
	QGet(ctx context.Context, kind string, property string, value string, entity Entity) (*datastore.Key, error)
	QueryParent(ctx context.Context, kind string, parent *datastore.Key, entitySlicePtr interface{}) ([]*datastore.Key, error)
}

func ConnectToDatastore

func ConnectToDatastore(ctx context.Context) (DatastoreClient, error)

ConnectToDatastore will establish a connection to Datastore and wrap the client in a DatastoreClient instance

type Entity

type Entity interface {
	GetKind() string
	GetValue() interface{}
}

value must be a pointer to a struct

Jump to

Keyboard shortcuts

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