Documentation ¶
Index ¶
- Constants
- Variables
- func GetCacheKey(k *datastore.Key) string
- func IsDatastoreError(err error) bool
- func NewKey(kind string, k interface{}) *datastore.Key
- func NormalizeKeys(keys interface{}, kind string, namespace string) ([]*datastore.Key, error)
- func WithClient(ctx context.Context, client *Client) context.Context
- type AfterSave
- type BeforeSave
- type Client
- func (c *Client) Close() error
- func (c *Client) Count(ctx context.Context, q *Query) (int, error)
- func (c *Client) DeleteAll(ctx context.Context, kind string) error
- func (c *Client) DeleteMulti(ctx context.Context, keys []*datastore.Key, options ...Option) error
- func (c *Client) GetAll(ctx context.Context, q *Query, dst interface{}) ([]*datastore.Key, error)
- func (c *Client) GetMulti(ctx context.Context, keys []*datastore.Key, entities interface{}, ...) error
- func (c *Client) PutMulti(ctx context.Context, keys []*datastore.Key, ent interface{}, options ...Option) ([]*datastore.Key, error)
- func (c *Client) Run(ctx context.Context, q *Query) (*datastore.Iterator, error)
- type Option
- type Query
- func (q *Query) Ancestor(a *datastore.Key) *Query
- func (q *Query) Asc(name string) *Query
- func (q *Query) Desc(name string) *Query
- func (q *Query) End(value string) *Query
- func (q *Query) Eq(name string, value interface{}) *Query
- func (q *Query) Ge(name string, value interface{}) *Query
- func (q *Query) Gt(name string, value interface{}) *Query
- func (q *Query) KeysOnly() *Query
- func (q *Query) Le(name string, value interface{}) *Query
- func (q *Query) Limit(value int) *Query
- func (q *Query) Lt(name string, value interface{}) *Query
- func (q *Query) Namespace(ns string) *Query
- func (q *Query) Ne(name string, value interface{}) *Query
- func (q *Query) Start(value string) *Query
- func (q *Query) String() string
- type TestEnv
Constants ¶
const CrudEntsLimit = 200
CrudEntsLimit is a limit of the number of entities that can be handled in one put or delete transaction
const LoggerKey = "gae.datastore"
LoggerKey is a key for logger in this package
Variables ¶
var ( // ErrTooManyEnts is returned when the user passes too many entities to PutMulti or DeleteMulti. ErrTooManyEnts = fmt.Errorf("too many entities to operate (max: %d)", CrudEntsLimit) )
Functions ¶
func GetCacheKey ¶
GetCacheKey returns a string representation for the cache key
func IsDatastoreError ¶
IsDatastoreError returns true if err is not ErrNoSuchEntity
func NewKey ¶
NewKey returns a new *datastore.Key for `kind`. if k is *datastore.Key, it returns the same object. if k is not a string nor an int, k is converted by fmt.Sprintf("%s").
func NormalizeKeys ¶
NormalizeKeys to normalize keys from []string, []interface{} to []*datastore.Key
Types ¶
type BeforeSave ¶
BeforeSave is an interface to run a logic before save
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper for datastore.Client
func FromContext ¶
FromContext returns a *Client for the current context
func NewClientFromClient ¶
NewClientFromClient returns a new *Client from the *datastore.Client
func (*Client) DeleteMulti ¶
DeleteMulti is wrapper for google.golang.org/appengine/datastore.DeleteMulti
func (*Client) GetAll ¶
GetAll fills the query result into dst and returns corresponding *datastore.Key
func (*Client) GetMulti ¶
func (c *Client) GetMulti(ctx context.Context, keys []*datastore.Key, entities interface{}, options ...Option) error
GetMulti is wrapper for google.golang.org/appengine/datastore.GetMulti
type Option ¶
type Option func(*clientConfig) *clientConfig
Option is a function to configure CRUD operation
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a wrapper for datasatore.Query
type TestEnv ¶
type TestEnv struct {
// contains filtered or unexported fields
}
TestEnv is a struct to provide a helper
func MustNewTestEnv ¶
func MustNewTestEnv() *TestEnv
MustNewTestEnv is like MustNewTestEnv, but panic if an error occurs
func (*TestEnv) LoadFixture ¶
LoadFixture loads the fixture data from `path`
func (*TestEnv) MustLoadFixture ¶
MustLoadFixture is like LoadFixture but panic if an error occurs