datastore

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerKey = "gae.datastore"

LoggerKey is a key for logger in this package

Variables

View Source
var FilterValueOmit = lazy.Value(nil)

FilterValueOmit is a value to omit the filter.

q.Eq("FieladName", lazy.LazyFunc(func(ctx) lazy.Value {
    v, ok :=  ctx.Value("filterValue").(string)
    if ok {
        return v;
    }
    return query.FilterValueOmit
}))

This means if 'filterValue' does not present in the context nor a int value, FieldName filter is not be applied in the query q.

Functions

func DeleteAll

func DeleteAll(ctx context.Context, kind string) error

DeleteAll deletes the all `kind` entities stored in datastore

func DeleteMulti

func DeleteMulti(ctx context.Context, keys []*datastore.Key) error

DeleteMulti is wrapper for google.golang.org/appengine/datastore.DeleteMulti to support +1000 keys

func GetMulti

func GetMulti(ctx context.Context, keys []*datastore.Key, ent interface{}) error

GetMulti is wrapper for google.golang.org/appengine/datastore.GetMulti to support +1000 keys

func IsDatastoreError

func IsDatastoreError(err error) bool

IsDatastoreError returns true if err is not ErrNoSuchEntity

func NewKey

func NewKey(ctx context.Context, kind string, k interface{}) *datastore.Key

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 PutMulti

func PutMulti(ctx context.Context, keys []*datastore.Key, ent interface{}) ([]*datastore.Key, error)

PutMulti is wrapper for google.golang.org/appengine/datastore.PutMulti to support +1000 keys

Types

type Query

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

Query is a struct to build a query to datastore.

func NewQuery

func NewQuery(kind string, loggerKey string) *Query

NewQuery returns a new *Query for `kind`

func (*Query) Ancestor

func (q *Query) Ancestor(a lazy.Value) *Query

Ancestor sets the ancestor filter

func (*Query) Asc

func (q *Query) Asc(name string) *Query

Asc specifies ascending order on the given filed.

func (*Query) Count

func (q *Query) Count(ctx context.Context) (int, error)

Count returns a count

func (*Query) Desc

func (q *Query) Desc(name string) *Query

Desc specifies descending order on the given filed.

func (*Query) End

func (q *Query) End(value lazy.Value) *Query

End sets the end cursor

func (*Query) Eq

func (q *Query) Eq(name string, value lazy.Value) *Query

Eq sets the "=" filter on the `name` field.

func (*Query) Ge

func (q *Query) Ge(name string, value lazy.Value) *Query

Ge sets the `>=` filter on the `name` field.

func (*Query) GetAll

func (q *Query) GetAll(ctx context.Context, dst interface{}) ([]*datastore.Key, error)

GetAll fills the query result into dst and returns corresponding *datastore.Key

func (*Query) Gt

func (q *Query) Gt(name string, value lazy.Value) *Query

Gt sets the `>` filter on the `name` field.

func (*Query) KeysOnly

func (q *Query) KeysOnly(t bool) *Query

KeysOnly sets the query to fetch only keys.

func (*Query) Le

func (q *Query) Le(name string, value lazy.Value) *Query

Le sets the `<=` filter on the `name` field.

func (*Query) Limit

func (q *Query) Limit(value lazy.Value) *Query

Limit sets the limit

func (*Query) Lt

func (q *Query) Lt(name string, value lazy.Value) *Query

Lt sets the `<` filter on the `name` field.

func (*Query) Ne

func (q *Query) Ne(name string, value lazy.Value) *Query

Ne sets the `!=` filter on the `name` field.

func (*Query) Run

func (q *Query) Run(ctx context.Context) (*datastore.Iterator, error)

Run runs a query and returns *datastore.Iterator

func (*Query) Start

func (q *Query) Start(value lazy.Value) *Query

Start sets the start cursor

Jump to

Keyboard shortcuts

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