Documentation ¶
Index ¶
- Constants
- Variables
- func Delete(s *session.Session) error
- func DeleteCurrent(ctx context.Context) error
- func Set(s *session.Session, a *Auth) error
- func SetCurrent(ctx context.Context, a *Auth) error
- type Auth
- type AuthKind
- func (k *AuthKind) Delete(ctx context.Context, key interface{}) (*datastore.Key, error)
- func (k *AuthKind) DeleteMatched(ctx context.Context, q *AuthQuery) (int, error)
- func (k *AuthKind) DeleteMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, error)
- func (k *AuthKind) EnforceNamespace(ns string, b bool) *AuthKind
- func (k *AuthKind) Get(ctx context.Context, key interface{}) (*datastore.Key, *Auth, error)
- func (k *AuthKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*Auth, error)
- func (k *AuthKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
- func (k *AuthKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
- func (k *AuthKind) MustGet(ctx context.Context, key interface{}) *Auth
- func (k *AuthKind) MustGetMulti(ctx context.Context, keys interface{}) []*Auth
- func (k *AuthKind) MustPut(ctx context.Context, ent *Auth) *datastore.Key
- func (k *AuthKind) MustPutMulti(ctx context.Context, ents []*Auth) []*datastore.Key
- func (k *AuthKind) MustReplace(ctx context.Context, ent *Auth, replacer AuthKindReplacer) (*datastore.Key, *Auth)
- func (k *AuthKind) MustReplaceMulti(ctx context.Context, ents []*Auth, replacer AuthKindReplacer) ([]*datastore.Key, []*Auth)
- func (k *AuthKind) Put(ctx context.Context, ent *Auth) (*datastore.Key, error)
- func (k *AuthKind) PutMulti(ctx context.Context, ents []*Auth) ([]*datastore.Key, error)
- func (k *AuthKind) Replace(ctx context.Context, ent *Auth, replacer AuthKindReplacer) (*datastore.Key, *Auth, error)
- func (k *AuthKind) ReplaceMulti(ctx context.Context, ents []*Auth, replacer AuthKindReplacer) ([]*datastore.Key, []*Auth, error)
- func (k *AuthKind) UseDefaultIfNil(b bool) *AuthKind
- type AuthKindReplacer
- type AuthKindReplacerFunc
- type AuthPagination
- type AuthQuery
- func (q *AuthQuery) Ancestor(a lazy.Value) *AuthQuery
- func (q *AuthQuery) Asc(name string) *AuthQuery
- func (q *AuthQuery) Count(ctx context.Context) (int, error)
- func (q *AuthQuery) Desc(name string) *AuthQuery
- func (q *AuthQuery) End(value lazy.Value) *AuthQuery
- func (q *AuthQuery) Eq(name string, value lazy.Value) *AuthQuery
- func (q *AuthQuery) Ge(name string, value lazy.Value) *AuthQuery
- func (q *AuthQuery) GetAll(ctx context.Context) ([]*datastore.Key, []*Auth, error)
- func (q *AuthQuery) GetAllValues(ctx context.Context) ([]*Auth, error)
- func (q *AuthQuery) Gt(name string, value lazy.Value) *AuthQuery
- func (q *AuthQuery) Le(name string, value lazy.Value) *AuthQuery
- func (q *AuthQuery) Limit(n lazy.Value) *AuthQuery
- func (q *AuthQuery) Lt(name string, value lazy.Value) *AuthQuery
- func (q *AuthQuery) MustCount(ctx context.Context) int
- func (q *AuthQuery) MustGetAll(ctx context.Context) ([]*datastore.Key, []*Auth)
- func (q *AuthQuery) MustGetAllValues(ctx context.Context) []*Auth
- func (q *AuthQuery) MustRun(ctx context.Context) *AuthPagination
- func (q *AuthQuery) Ne(name string, value lazy.Value) *AuthQuery
- func (q *AuthQuery) Run(ctx context.Context) (*AuthPagination, error)
- func (q *AuthQuery) Start(value lazy.Value) *AuthQuery
- func (q *AuthQuery) ViaKeys(k *AuthKind) *AuthQuery
- type AuthType
Constants ¶
const AuthKindLoggerKey = "ent.auth"
AuthKindLoggerKey is a logger key name for the ent
const AuthQueryLoggerKey = "ent.query.auth"
AuthQueryLoggerKey is a logger key name for the ent
Variables ¶
var DefaultAuthKind = &AuthKind{}
DefaultAuthKind is a default value of *AuthKind
var ErrNoSession = fmt.Errorf("no session is available in the context")
var Guest = &Auth{ ID: "guest", FacebookID: "guest", MessengerID: "guest", TwitterID: "guest", Email: "", AuthType: AuthTypeNone, CreatedAt: time.Time{}, LastLoginAt: time.Time{}, UpdatedAt: time.Time{}, }
Guest is a unauthorized value.
Functions ¶
func DeleteCurrent ¶
DeleteCurrent is to delete the auth fron the current session
Types ¶
type Auth ¶
type Auth struct { ID string `json:"id" ent:"id"` FacebookID string `json:"facebook_id"` MessengerID string `json:"messenger_id"` TwitterID string `json:"twitter_id"` Email string `json:"email"` AuthType AuthType `json:"auth_type"` IsAdmin bool `json:"is_admin"` CreatedAt time.Time `json:"created_at"` LastLoginAt time.Time `json:"last_login_at"` UpdatedAt time.Time `json:"updated_at" ent:"timestamp"` }
Auth is a primary type to represent a user
func GetCurrent ¶
GetCurrent is to get the auth fron the current session
func (*Auth) UpdateByForm ¶
UpdateByForm updates the fields by form values. All values should be validated before calling this function.
type AuthKind ¶
type AuthKind struct {
// contains filtered or unexported fields
}
func (*AuthKind) DeleteMatched ¶
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 (*AuthKind) DeleteMulti ¶
DeleteMulti do Delete with multiple keys
func (*AuthKind) EnforceNamespace ¶
EnforceNamespace enforces namespace for Get/Put/Delete or not.
func (*AuthKind) GetMulti ¶
func (k *AuthKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*Auth, error)
GetMulti do Get with multiple keys. keys must be []string, []*datastore.Key, or []interface{}
func (*AuthKind) MustDelete ¶
MustDelete is like Delete but panic if an error occurs
func (*AuthKind) MustDeleteMulti ¶
MustDeleteMulti is like DeleteMulti but panic if an error occurs
func (*AuthKind) MustGetMulti ¶
MustGetMulti is like GetMulti but returns only values and panic if error happens.
func (*AuthKind) MustPutMulti ¶
MustPutMulti is like PutMulti but panic if an error occurs
func (*AuthKind) MustReplace ¶
func (*AuthKind) MustReplaceMulti ¶
func (*AuthKind) ReplaceMulti ¶
func (*AuthKind) UseDefaultIfNil ¶
type AuthKindReplacer ¶
type AuthKindReplacerFunc ¶
type AuthPagination ¶
type AuthQuery ¶
type AuthQuery struct {
// contains filtered or unexported fields
}
AuthQuery helps to build and execute a query
func NewAuthQuery ¶
func NewAuthQuery() *AuthQuery
func (*AuthQuery) GetAllValues ¶
GetAllValues is like GetAll but returns only values
func (*AuthQuery) MustGetAll ¶
MustGetAll is like GetAll but panic if an error occurrs.
func (*AuthQuery) MustGetAllValues ¶
MustGetAllValues is like GetAllValues but panic if an error occurrs
func (*AuthQuery) MustRun ¶
func (q *AuthQuery) MustRun(ctx context.Context) *AuthPagination
MustRun is like Run but panic if an error occurrs
func (*AuthQuery) Run ¶
func (q *AuthQuery) Run(ctx context.Context) (*AuthPagination, error)
Run returns the a result as *AuthPagination object
type AuthType ¶
type AuthType int
AuthType is an enum for authentication types.
const ( AuthTypeNone AuthType = iota AuthTypeEmail AuthTypeFacebook AuthTypeTwitter AuthTypeMessenger AuthTypeGoogle )
AuthType values