Documentation ¶
Index ¶
- Constants
- func AncestorCounter(model interface{}, fields ...string) ...
- func AncestorFinder(model interface{}, fields ...string) ...
- func Counter(model interface{}, fields ...string) func(c PersistenceContext, values ...interface{}) (int, error)
- func Del(c PersistenceContext, src interface{}) (err error)
- func DelAll(c PersistenceContext, src interface{}) (err error)
- func DelQuery(c PersistenceContext, src interface{}, q *datastore.Query) (err error)
- func FilterOkErrors(err error, accepted ...error) (result error)
- func Finder(model interface{}, fields ...string) func(c PersistenceContext, dst interface{}, values ...interface{}) error
- func GetAll(c PersistenceContext, src interface{}) (err error)
- func GetById(c PersistenceContext, dst interface{}) (err error)
- func GetKinds(c context.Context) (result []string, err error)
- func GetMulti(c PersistenceContext, ids []key.Key, src interface{}) (err error)
- func GetQuery(c PersistenceContext, src interface{}, q *datastore.Query) (err error)
- func MemcacheDel(c PersistenceContext, model interface{}) (err error)
- func MemcacheKeys(c PersistenceContext, model interface{}, oldKeys *[]string) (newKeys []string, err error)
- func Put(c PersistenceContext, src interface{}) (err error)
- func PutMulti(c PersistenceContext, src interface{}) (err error)
- type ErrNoSuchEntity
- type LogStats
- type PersistenceContext
- type StatusMap
Constants ¶
const ( BeforeCreateName = "BeforeCreate" BeforeUpdateName = "BeforeUpdate" BeforeSaveName = "BeforeSave" BeforeDeleteName = "BeforeDelete" AfterCreateName = "AfterCreate" AfterUpdateName = "AfterUpdate" AfterSaveName = "AfterSave" AfterLoadName = "AfterLoad" AfterDeleteName = "AfterDelete" )
Variables ¶
This section is empty.
Functions ¶
func AncestorCounter ¶
func AncestorFinder ¶
func AncestorFinder(model interface{}, fields ...string) func(c PersistenceContext, dst interface{}, ancestor key.Key, values ...interface{}) error
AncestorFinder will return a finder function that memoizes running a datastore query to find matching models.
It will also register the finder so that MemcacheKeys will return keys to invalidate the result each time a matching model is CRUDed.
The returned function will set the Id field of all found models, and call their AfterLoad functions if any.
func Counter ¶
func Counter(model interface{}, fields ...string) func(c PersistenceContext, values ...interface{}) (int, error)
func Del ¶
func Del(c PersistenceContext, src interface{}) (err error)
Del will delete src from datastore and invalidate it from memcache.
It will also load any old entities with the same id from datastore and run Before/AfterDelete on them
func DelAll ¶
func DelAll(c PersistenceContext, src interface{}) (err error)
func DelQuery ¶
func DelQuery(c PersistenceContext, src interface{}, q *datastore.Query) (err error)
DelQuery will delete (from datastore and memcache) all entities of type src that matches q. src must be a pointer to a struct type.
func FilterOkErrors ¶
FilterOkErrors will return nil if the provided error is a FieldMismatch, one of the accepted errors, or an appengine.MultiError combination thereof, Otherwise it will return err.
func Finder ¶
func Finder(model interface{}, fields ...string) func(c PersistenceContext, dst interface{}, values ...interface{}) error
Finder will return a finder function that runs a datastore query to find matching models.
The returned function will set the Id field of all found models, and call their AfterLoad functions if any.
func GetAll ¶
func GetAll(c PersistenceContext, src interface{}) (err error)
func GetById ¶
func GetById(c PersistenceContext, dst interface{}) (err error)
GetById will find memoize finding dst in the datastore, setting its id and running its AfterLoad function, if any.
func GetQuery ¶
func GetQuery(c PersistenceContext, src interface{}, q *datastore.Query) (err error)
func MemcacheDel ¶
func MemcacheDel(c PersistenceContext, model interface{}) (err error)
func MemcacheKeys ¶
func MemcacheKeys(c PersistenceContext, model interface{}, oldKeys *[]string) (newKeys []string, err error)
MemcacheKeys will append to oldKeys, and also return as newKeys, any memcache keys this package knows about that would result in the provided model being found.
It will use the id based key, and any memcache keys provided by finders created by Finder or AncestorFinder.
func Put ¶
func Put(c PersistenceContext, src interface{}) (err error)
Put will save src in datastore, invalidating cache and running hooks. This requires the loading of any old versions currently in the datastore, which will cause some extra work.
func PutMulti ¶
func PutMulti(c PersistenceContext, src interface{}) (err error)
PutMulti will save src in datastore, invalidating cache and running hooks. This requires the loading of any old versions currently in the datastore, which will cause some extra work.
Types ¶
type ErrNoSuchEntity ¶
ErrNoSuchEntity is just an easily identifiable way of determining that we didn't find what we were looking for, while still providing something the httpcontext types can render as an http response.
func (ErrNoSuchEntity) Error ¶
func (self ErrNoSuchEntity) Error() string
func (ErrNoSuchEntity) GetStatus ¶
func (self ErrNoSuchEntity) GetStatus() int
func (ErrNoSuchEntity) Respond ¶
func (self ErrNoSuchEntity) Respond(c httpcontext.HTTPContext) (err error)
type LogStats ¶
type PersistenceContext ¶
type PersistenceContext interface { memcache.TransactionContext AfterCreate(interface{}) error AfterSave(interface{}) error AfterUpdate(interface{}) error BeforeCreate(interface{}) error BeforeSave(interface{}) error BeforeUpdate(interface{}) error AfterLoad(interface{}) error AfterDelete(interface{}) error BeforeDelete(interface{}) error }