Documentation ¶
Overview ¶
The ds pgk creates a simple wrapper around common Datastore functions to facilitate unit testing
Index ¶
- func Export(ctx context.Context, timeout int, project string, bucket string, ...) ([]byte, error)
- type Client
- func (client Client) Client() *datastore.Client
- func (client Client) Create(ctx context.Context, parent *datastore.Key, entity Entity) (*datastore.Key, error)
- func (client Client) CreateNamed(ctx context.Context, name string, parent *datastore.Key, entity Entity) (*datastore.Key, error)
- func (client Client) Delete(ctx context.Context, kind string, id int64, parent *datastore.Key) error
- func (client Client) DeleteNamed(ctx context.Context, kind string, name string, parent *datastore.Key) error
- func (client Client) Get(ctx context.Context, id int64, parent *datastore.Key, entity Entity) error
- func (client Client) GetNamed(ctx context.Context, name string, parent *datastore.Key, entity Entity) error
- func (client Client) QGet(ctx context.Context, kind string, property string, value string, entity Entity) (*datastore.Key, error)
- func (client Client) QueryParent(ctx context.Context, kind string, parent *datastore.Key, ...) ([]*datastore.Key, error)
- func (client Client) Update(ctx context.Context, parent *datastore.Key, id int64, entity Entity) (*datastore.Key, error)
- type DatastoreClient
- type Entity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
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) 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
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