gds

package
v0.0.0-...-6152d30 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package gds provides the basic APIs to communicate with Google datastore

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildGdsContext

func BuildGdsContext(serviceEmail string, key []byte, projectID string) (context.Context, *datastore.Client, error)

BuildGdsContext builds the singlton context for Manager

Types

type Cloneable

type Cloneable interface {
	Clone() interface{}
}

type Manager

type Manager struct {
	SuffixOfKind string

	Client *datastore.Client `inject:""`
}

Manager is for low level communication with Google datastore

func (*Manager) BatchIterate

func (m *Manager) BatchIterate(
	query *datastore.Query,
	batchSize int,
	dst Cloneable,
	op func(key *datastore.Key, dst interface{})) error

Batch iterates the query result with customized step

func (*Manager) BuildKey

func (m *Manager) BuildKey(kind, keyName string) *datastore.Key

BuildKey builds the datastore entity key of specific name

func (*Manager) Delete

func (m *Manager) Delete(key *datastore.Key) error

Delete deletes the entity by key (if the entity is not existed, there is no error)

func (*Manager) DeleteAll

func (m *Manager) DeleteAll(kindName string) error

DeleteAll deletes all entities under some Kind

func (*Manager) Get

func (m *Manager) Get(key *datastore.Key, entity interface{}) error

Get gets the entity by key

func (*Manager) GetAll

func (m *Manager) GetAll(query *datastore.Query, result interface{}) ([]*datastore.Key, error)

GetAll fetchs all entities by the query. The parameter `result` should be type of `*[]*<Entity>`

func (*Manager) GetCount

func (m *Manager) GetCount(query *datastore.Query) (int, error)

GetCount return count of result

func (*Manager) GetKeysOnly

func (m *Manager) GetKeysOnly(query *datastore.Query) ([]*datastore.Key, error)

GetKeysOnly gets only keys bu query

func (*Manager) GetMulti

func (m *Manager) GetMulti(keys []*datastore.Key, dst interface{}) error

GetMulti gets the entities by keys

func (*Manager) GetTx

func (m *Manager) GetTx() *datastore.Transaction

GetTx gets the datastore transaction

func (*Manager) Iterate

func (m *Manager) Iterate(
	query *datastore.Query,
	cursorStr string,
	dst Cloneable,
	op func(key *datastore.Key, dst interface{})) (string, error)

Iterate iterates one by one to the query result

func (*Manager) Put

func (m *Manager) Put(key *datastore.Key, entity interface{}) (*datastore.Key, error)

Put inserts/updates the entity

func (*Manager) PutUnique

func (m *Manager) PutUnique(key *datastore.Key, entity interface{}) error

PutUnique inserts/updates entity with unique key (if the same key existed, issue error)

func (*Manager) Setup

func (m *Manager) Setup(suffixOfKind string)

Setup sets the suffix of kind

Jump to

Keyboard shortcuts

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