query

package
v1.47.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Done signals end of iteration
	Done = errors.New("datastore: done")

	// Custom Errors - these are package-local to avoid conflicts with dot-imported utils
	InvalidKey  = db.ErrInvalidKey
	KeyNotFound = db.ErrNoSuchEntity
)

Functions

func New

func New(ctx context.Context, kind string) iface.Query

New creates a new Query for the given kind. Uses the default database if one was set via SetDefaultDB.

func NewWithDB

func NewWithDB(ctx context.Context, kind string, database db.DB) iface.Query

NewWithDB creates a new Query with an explicit database

func SetDefaultDB

func SetDefaultDB(database db.DB)

SetDefaultDB sets the global default database used by New().

Types

type Id

type Id struct {
	Id_ string
}

type Kind

type Kind interface {
	Kind() string
}

type Model

type Model interface {
	SetContext(ctx context.Context)
	SetEntity(entity interface{})
	SetKey(key interface{}) error
}

Subset of model API needed to initialize a model correctly.

type Query

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

Query implements iface.Query using the new db package

func (*Query) Ancestor

func (q *Query) Ancestor(ancestor iface.Key) iface.Query

func (*Query) ById

func (q *Query) ById(id string, dst interface{}) (iface.Key, bool, error)

Query for entity by id

func (*Query) ByKey

func (q *Query) ByKey(k iface.Key, dst interface{}) (iface.Key, bool, error)

func (*Query) Count

func (q *Query) Count() (int, error)

func (*Query) Distinct

func (q *Query) Distinct() iface.Query

func (*Query) End

func (q *Query) End(c iface.Cursor) iface.Query

func (*Query) EventualConsistency

func (q *Query) EventualConsistency() iface.Query

func (*Query) Filter

func (q *Query) Filter(filterStr string, value interface{}) iface.Query

func (*Query) First

func (q *Query) First(dst interface{}) (iface.Key, bool, error)

Fetches first entity

func (*Query) FirstKey

func (q *Query) FirstKey() (iface.Key, bool, error)

Fetches first key

func (*Query) GetAll

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

Fetches entities. Dst must have type *[]S or *[]*S or *[]P, for some struct type S or some non- interface, non-pointer type P such that P or *P implements PropertyLoadSaver.

func (*Query) GetKeys

func (q *Query) GetKeys() ([]iface.Key, error)

Fetches keys only

func (*Query) GetModels

func (q *Query) GetModels(dst interface{}) error

Fetches models and initializes them automatically. Dst must have type *[]*M, for some model type M.

func (*Query) IdExists

func (q *Query) IdExists(id string) (iface.Key, bool, error)

Returns true if entity with key that encodes to id is persisted to datastore

func (*Query) KeyExists

func (q *Query) KeyExists(k iface.Key) (bool, error)

Returns true if entity with key is persisted to datastore

func (*Query) KeysOnly

func (q *Query) KeysOnly() iface.Query

func (*Query) Limit

func (q *Query) Limit(limit int) iface.Query

func (*Query) Offset

func (q *Query) Offset(offset int) iface.Query

func (*Query) Order

func (q *Query) Order(fieldName string) iface.Query

func (*Query) Project

func (q *Query) Project(fieldNames ...string) iface.Query

func (*Query) Run

func (q *Query) Run() iface.Iterator

func (*Query) Start

func (q *Query) Start(c iface.Cursor) iface.Query

Jump to

Keyboard shortcuts

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