gosto: github.com/timakin/gosto Index | Files

package gosto

import "github.com/timakin/gosto"

Index

Package Files

entity.go gosto.go query.go

Variables

var (
    // IgnoreFieldMismatch decides whether *datastore.ErrFieldMismatch errors
    // should be silently ignored. This allows you to easily remove fields from structs.
    IgnoreFieldMismatch = true
)

func DefaultKindName Uses

func DefaultKindName(src interface{}) string

DefaultKindName is the default implementation to determine the Kind an Entity has. Returns the basic Type of the src (no package name included).

func NotFound Uses

func NotFound(err error, idx int) bool

NotFound returns true if err is an datastore.MultiError and err[idx] is a datastore.ErrNoSuchEntity.

type Gosto Uses

type Gosto struct {
    Context  context.Context
    DSClient *datastore.Client

    // KindNameResolver is used to determine what Kind to give an Entity.
    // Defaults to DefaultKindName
    KindNameResolver KindNameResolver
    // contains filtered or unexported fields
}

Gosto holds the context and the request memory cache.

func NewGosto Uses

func NewGosto(ctx context.Context, projectID string) (*Gosto, error)

NewGosto creates a new Gosto object from the given request.

func (*Gosto) Count Uses

func (g *Gosto) Count(q *datastore.Query) (int, error)

Count returns the number of results for the query.

func (*Gosto) Delete Uses

func (g *Gosto) Delete(key *datastore.Key) error

Delete deletes the entity for the given key.

func (*Gosto) DeleteMulti Uses

func (g *Gosto) DeleteMulti(keys []*datastore.Key) error

DeleteMulti is a batch version of Delete.

func (*Gosto) Get Uses

func (g *Gosto) Get(dst interface{}) error

Get loads the entity based on dst's key into dst If there is no such entity for the key, Get returns datastore.ErrNoSuchEntity.

func (*Gosto) GetAll Uses

func (g *Gosto) GetAll(q *datastore.Query, dst interface{}) ([]*datastore.Key, error)

GetAll runs the query and returns all the keys that match the query, as well as appending the values to dst, setting the Gosto key fields of dst, and caching the returned data in local memory.

For "keys-only" queries dst can be nil, however if it is not, then GetAll appends zero value structs to dst, only setting the Gosto key fields. No data is cached with "keys-only" queries.

See: https://developers.google.com/appengine/docs/go/datastore/reference#Query.GetAll

func (*Gosto) GetMulti Uses

func (g *Gosto) GetMulti(dst interface{}) error

GetMulti is a batch version of Get.

dst must be a *[]S, *[]*S, *[]I, []S, []*S, or []I, for some struct type S, or some interface type I. If *[]I or []I, each element must be a struct pointer.

func (*Gosto) Key Uses

func (g *Gosto) Key(src interface{}) *datastore.Key

Key is the same as KeyError, except nil is returned on error or if the key is incomplete.

func (*Gosto) KeyError Uses

func (g *Gosto) KeyError(src interface{}) (*datastore.Key, error)

KeyError returns the key of src based on its properties.

func (*Gosto) Kind Uses

func (g *Gosto) Kind(src interface{}) string

Kind returns src's datastore Kind or "" on error.

func (*Gosto) Put Uses

func (g *Gosto) Put(src interface{}) (*datastore.Key, error)

Put saves the entity src into the datastore based on src's key k. If k is an incomplete key, the returned key will be a unique key generated by the datastore.

func (*Gosto) PutMulti Uses

func (g *Gosto) PutMulti(src interface{}) ([]*datastore.Key, error)

PutMulti is a batch version of Put.

src must be a *[]S, *[]*S, *[]I, []S, []*S, or []I, for some struct type S, or some interface type I. If *[]I or []I, each element must be a struct pointer.

func (*Gosto) Run Uses

func (g *Gosto) Run(q *datastore.Query) *Iterator

Run runs the query.

func (*Gosto) RunInTransaction Uses

func (g *Gosto) RunInTransaction(f func(tx *datastore.Transaction) error, opts ...datastore.TransactionOption) error

RunInTransaction runs f in a transaction. It calls f with a transaction context tg that f should use for all the transaction's datastore operations.

https://godoc.org/cloud.google.com/go/datastore#Client.RunInTransaction

type Iterator Uses

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

func (*Iterator) Cursor Uses

func (t *Iterator) Cursor() (datastore.Cursor, error)

func (*Iterator) Next Uses

func (t *Iterator) Next(dst interface{}) (*datastore.Key, error)

type KindNameResolver Uses

type KindNameResolver func(src interface{}) string

KindNameResolver takes an Entity and returns what the Kind should be for Datastore.

Package gosto imports 11 packages (graph). Updated 2017-09-20. Refresh now. Tools for package owners.