Documentation ¶
Index ¶
- Constants
- Variables
- type A
- type AliasNotUsed
- type Example
- type ExampleKind
- func (k *ExampleKind) Delete(ctx context.Context, key interface{}) (*datastore.Key, error)
- func (k *ExampleKind) DeleteMatched(ctx context.Context, q *ExampleQuery) (int, error)
- func (k *ExampleKind) DeleteMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, error)
- func (k *ExampleKind) EnforceNamespace(ns string, b bool) *ExampleKind
- func (k *ExampleKind) Get(ctx context.Context, key interface{}) (*datastore.Key, *Example, error)
- func (k *ExampleKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*Example, error)
- func (k *ExampleKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
- func (k *ExampleKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
- func (k *ExampleKind) MustGet(ctx context.Context, key interface{}) *Example
- func (k *ExampleKind) MustGetMulti(ctx context.Context, keys interface{}) []*Example
- func (k *ExampleKind) MustPut(ctx context.Context, ent *Example) *datastore.Key
- func (k *ExampleKind) MustPutMulti(ctx context.Context, ents []*Example) []*datastore.Key
- func (k *ExampleKind) MustReplace(ctx context.Context, ent *Example, replacer ExampleKindReplacer) (*datastore.Key, *Example)
- func (k *ExampleKind) MustReplaceMulti(ctx context.Context, ents []*Example, replacer ExampleKindReplacer) ([]*datastore.Key, []*Example)
- func (k *ExampleKind) Put(ctx context.Context, ent *Example) (*datastore.Key, error)
- func (k *ExampleKind) PutMulti(ctx context.Context, ents []*Example) ([]*datastore.Key, error)
- func (k *ExampleKind) Replace(ctx context.Context, ent *Example, replacer ExampleKindReplacer) (*datastore.Key, *Example, error)
- func (k *ExampleKind) ReplaceMulti(ctx context.Context, ents []*Example, replacer ExampleKindReplacer) ([]*datastore.Key, []*Example, error)
- func (k *ExampleKind) SearchKeys(ctx context.Context, query string, opts *search.SearchOptions) (*ExamplePagination, error)
- func (k *ExampleKind) SearchValues(ctx context.Context, query string, opts *search.SearchOptions) (*ExamplePagination, error)
- func (k *ExampleKind) UseDefaultIfNil(b bool) *ExampleKind
- type ExampleKindReplacer
- type ExampleKindReplacerFunc
- type ExamplePagination
- type ExampleQuery
- func (q *ExampleQuery) Ancestor(a lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Asc(name string) *ExampleQuery
- func (q *ExampleQuery) Count(ctx context.Context) (int, error)
- func (q *ExampleQuery) Desc(name string) *ExampleQuery
- func (q *ExampleQuery) End(value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Eq(name string, value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Ge(name string, value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) GetAll(ctx context.Context) ([]*datastore.Key, []*Example, error)
- func (q *ExampleQuery) GetAllValues(ctx context.Context) ([]*Example, error)
- func (q *ExampleQuery) Gt(name string, value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Le(name string, value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Limit(n lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Lt(name string, value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) MustCount(ctx context.Context) int
- func (q *ExampleQuery) MustGetAll(ctx context.Context) ([]*datastore.Key, []*Example)
- func (q *ExampleQuery) MustGetAllValues(ctx context.Context) []*Example
- func (q *ExampleQuery) MustRun(ctx context.Context) *ExamplePagination
- func (q *ExampleQuery) Ne(name string, value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) Run(ctx context.Context) (*ExamplePagination, error)
- func (q *ExampleQuery) Start(value lazy.Value) *ExampleQuery
- func (q *ExampleQuery) ViaKeys(k *ExampleKind) *ExampleQuery
- type ExampleSearchDoc
Constants ¶
const ExampleKindLoggerKey = "ent.example"
ExampleKindLoggerKey is a logger key name for the ent
const ExampleQueryLoggerKey = "ent.query.example"
ExampleQueryLoggerKey is a logger key name for the ent
const ExampleSearchIndexName = "ent.Example"
Variables ¶
var DefaultExampleKind = &ExampleKind{}
DefaultExampleKind is a default value of *ExampleKind
Functions ¶
This section is empty.
Types ¶
type AliasNotUsed ¶
type AliasNotUsed int
type Example ¶
type Example struct { ID string `json:"id" ent:"id"` Digit int `json:"digit" ent:"form,resetifmissing" default:"10"` Desc string `json:"desc" ent:"form,search" default:"This is default value"` ContentBytes []byte `json:"content_bytes" ent:"form,search"` SliceType []string `json:"slice_type" ent:"form"` BoolType bool `json:"bool_type" ent:"form,search"` FloatType float64 `json:"float_type" ent:"form,search"` CreatedAt time.Time `json:"created_at" default:"$now"` UpdatedAt time.Time `json:"updated_at" ent:"timestamp"` DefaultTime time.Time `json:"default_time" default:"2016-01-01T20:12:10Z"` BeforeSaveProcessed bool `json:"before_save_processed"` CustomType rgb.RGB `json:"custom_type" ent:"form" parser:"github.com/speedland/go/rgb.MustParseRGB"` Location appengine.GeoPoint `json:"location" ent:"search"` }
Example is an example of datastore model.
func NewExample ¶
func NewExample() *Example
NewExample returns a new *Example with default field values.
func (*Example) ToSearchDoc ¶
func (e *Example) ToSearchDoc() *ExampleSearchDoc
ToSearchDoc returns a new *ExampleSearchDoc
func (*Example) UpdateByForm ¶
UpdateByForm updates the fields by form values. All values should be validated before calling this function.
type ExampleKind ¶
type ExampleKind struct {
// contains filtered or unexported fields
}
func (*ExampleKind) DeleteMatched ¶
func (k *ExampleKind) DeleteMatched(ctx context.Context, q *ExampleQuery) (int, error)
DeleteMatched deletes the all ents that match with the query. This func modify Limit/StartKey condition in the query so that you should restore it if you want to reuse the query.
func (*ExampleKind) DeleteMulti ¶
DeleteMulti do Delete with multiple keys
func (*ExampleKind) EnforceNamespace ¶
func (k *ExampleKind) EnforceNamespace(ns string, b bool) *ExampleKind
EnforceNamespace enforces namespace for Get/Put/Delete or not.
func (*ExampleKind) GetMulti ¶
func (k *ExampleKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*Example, error)
GetMulti do Get with multiple keys. keys must be []string, []*datastore.Key, or []interface{}
func (*ExampleKind) MustDelete ¶
func (k *ExampleKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
MustDelete is like Delete but panic if an error occurs
func (*ExampleKind) MustDeleteMulti ¶
func (k *ExampleKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
MustDeleteMulti is like DeleteMulti but panic if an error occurs
func (*ExampleKind) MustGet ¶
func (k *ExampleKind) MustGet(ctx context.Context, key interface{}) *Example
MustGet is like Get but returns only values and panic if error happens.
func (*ExampleKind) MustGetMulti ¶
func (k *ExampleKind) MustGetMulti(ctx context.Context, keys interface{}) []*Example
MustGetMulti is like GetMulti but returns only values and panic if error happens.
func (*ExampleKind) MustPutMulti ¶
MustPutMulti is like PutMulti but panic if an error occurs
func (*ExampleKind) MustReplace ¶
func (k *ExampleKind) MustReplace(ctx context.Context, ent *Example, replacer ExampleKindReplacer) (*datastore.Key, *Example)
func (*ExampleKind) MustReplaceMulti ¶
func (k *ExampleKind) MustReplaceMulti(ctx context.Context, ents []*Example, replacer ExampleKindReplacer) ([]*datastore.Key, []*Example)
func (*ExampleKind) Replace ¶
func (k *ExampleKind) Replace(ctx context.Context, ent *Example, replacer ExampleKindReplacer) (*datastore.Key, *Example, error)
func (*ExampleKind) ReplaceMulti ¶
func (k *ExampleKind) ReplaceMulti(ctx context.Context, ents []*Example, replacer ExampleKindReplacer) ([]*datastore.Key, []*Example, error)
func (*ExampleKind) SearchKeys ¶
func (k *ExampleKind) SearchKeys(ctx context.Context, query string, opts *search.SearchOptions) (*ExamplePagination, error)
SearchKeys returns the a result as *ExamplePagination object. It only containd valid []*datastore.Keys
func (*ExampleKind) SearchValues ¶
func (k *ExampleKind) SearchValues(ctx context.Context, query string, opts *search.SearchOptions) (*ExamplePagination, error)
SearchValues returns the a result as *ExamplePagination object with filling Data field.
func (*ExampleKind) UseDefaultIfNil ¶
func (k *ExampleKind) UseDefaultIfNil(b bool) *ExampleKind
type ExampleKindReplacer ¶
type ExampleKindReplacerFunc ¶
type ExamplePagination ¶
type ExampleQuery ¶
type ExampleQuery struct {
// contains filtered or unexported fields
}
ExampleQuery helps to build and execute a query
func NewExampleQuery ¶
func NewExampleQuery() *ExampleQuery
func (*ExampleQuery) Ancestor ¶
func (q *ExampleQuery) Ancestor(a lazy.Value) *ExampleQuery
Ancestor sets the ancestor filter
func (*ExampleQuery) Asc ¶
func (q *ExampleQuery) Asc(name string) *ExampleQuery
Asc specifies ascending order on the given filed.
func (*ExampleQuery) Count ¶
func (q *ExampleQuery) Count(ctx context.Context) (int, error)
Count returns the count of entities
func (*ExampleQuery) Desc ¶
func (q *ExampleQuery) Desc(name string) *ExampleQuery
Desc specifies descending order on the given filed.
func (*ExampleQuery) End ¶
func (q *ExampleQuery) End(value lazy.Value) *ExampleQuery
Limit specifies the numbe of limit returend by this query.
func (*ExampleQuery) Eq ¶
func (q *ExampleQuery) Eq(name string, value lazy.Value) *ExampleQuery
Eq sets the "=" filter on the name field.
func (*ExampleQuery) Ge ¶
func (q *ExampleQuery) Ge(name string, value lazy.Value) *ExampleQuery
Ge sets the ">=" filter on the "name" field.
func (*ExampleQuery) GetAllValues ¶
func (q *ExampleQuery) GetAllValues(ctx context.Context) ([]*Example, error)
GetAllValues is like GetAll but returns only values
func (*ExampleQuery) Gt ¶
func (q *ExampleQuery) Gt(name string, value lazy.Value) *ExampleQuery
Gt sets the ">" filter on the "name" field.
func (*ExampleQuery) Le ¶
func (q *ExampleQuery) Le(name string, value lazy.Value) *ExampleQuery
Le sets the "<=" filter on the "name" field.
func (*ExampleQuery) Limit ¶
func (q *ExampleQuery) Limit(n lazy.Value) *ExampleQuery
Limit specifies the numbe of limit returend by this query.
func (*ExampleQuery) Lt ¶
func (q *ExampleQuery) Lt(name string, value lazy.Value) *ExampleQuery
Lt sets the "<" filter on the "name" field.
func (*ExampleQuery) MustCount ¶
func (q *ExampleQuery) MustCount(ctx context.Context) int
MustCount returns the count of entities
func (*ExampleQuery) MustGetAll ¶
MustGetAll is like GetAll but panic if an error occurrs.
func (*ExampleQuery) MustGetAllValues ¶
func (q *ExampleQuery) MustGetAllValues(ctx context.Context) []*Example
MustGetAllValues is like GetAllValues but panic if an error occurrs
func (*ExampleQuery) MustRun ¶
func (q *ExampleQuery) MustRun(ctx context.Context) *ExamplePagination
MustRun is like Run but panic if an error occurrs
func (*ExampleQuery) Ne ¶
func (q *ExampleQuery) Ne(name string, value lazy.Value) *ExampleQuery
Ne sets the "!=" filter on the "name" field.
func (*ExampleQuery) Run ¶
func (q *ExampleQuery) Run(ctx context.Context) (*ExamplePagination, error)
Run returns the a result as *ExamplePagination object
func (*ExampleQuery) Start ¶
func (q *ExampleQuery) Start(value lazy.Value) *ExampleQuery
Limit specifies the numbe of limit returend by this query.
func (*ExampleQuery) ViaKeys ¶
func (q *ExampleQuery) ViaKeys(k *ExampleKind) *ExampleQuery
ViaKeys optimize to execute keys-only query then call k.GetMulti() to fetch values. This would reduce the datastore query and maximize the memcache usage if the query called many times in a short time window.