Documentation ¶
Index ¶
- Constants
- type ACL
- func (acl *ACL) GetPublicReadAccess() bool
- func (acl *ACL) GetPublicWriteAccess() bool
- func (acl *ACL) GetReadAccess(user *User) bool
- func (acl *ACL) GetRoleReadAccess(role *Role) bool
- func (acl *ACL) GetRoleWriteAccess(role *Role) bool
- func (acl *ACL) GetWriteAccess(user *User) bool
- func (acl *ACL) SetPublicReadAccess(allowed bool)
- func (acl *ACL) SetPublicWriteAccess(allowed bool)
- func (acl *ACL) SetReadAccess(user *User, allowed bool)
- func (acl *ACL) SetRoleReadAccess(role *Role, allowed bool)
- func (acl *ACL) SetRoleWriteAccess(role *Role, allowed bool)
- func (acl *ACL) SetWriteAccess(user *User, allowed bool)
- type AuthData
- type AuthOption
- type Class
- type ClassHookRequest
- type Client
- func (client *Client) Class(name string) *Class
- func (client *Client) File(id string) *FileRef
- func (client *Client) Object(object interface{}) *ObjectRef
- func (client *Client) RPC(name string, params interface{}, results interface{}, runOptions ...RunOption) error
- func (client *Client) Role(id string) *RoleRef
- func (client *Client) Run(name string, params interface{}, runOptions ...RunOption) (interface{}, error)
- func (client *Client) SetProduction(production bool)
- func (client *Client) User(user interface{}) *UserRef
- type ClientOptions
- type CloudEngine
- type CloudError
- type DefineOption
- type File
- type FileRef
- type Files
- func (ref *Files) NewQuery() *Query
- func (ref *Files) Upload(file *File, reader io.ReadSeeker, authOptions ...AuthOption) error
- func (ref *Files) UploadFromLocalFile(file *File, path string, authOptions ...AuthOption) error
- func (ref *Files) UploadFromURL(file *File, authOptions ...AuthOption) error
- type FunctionRequest
- type GeoPoint
- type Object
- func (object *Object) ACL() *ACL
- func (object *Object) Bool(key string) bool
- func (object *Object) Bytes(key string) []byte
- func (object *Object) Clone(dst interface{}) error
- func (object *Object) Date(key string) *time.Time
- func (object *Object) File(key string) *File
- func (object *Object) Float(key string) float64
- func (object *Object) GeoPoint(key string) *GeoPoint
- func (object *Object) Get(key string) interface{}
- func (object *Object) Included() bool
- func (object *Object) Int(key string) int64
- func (object *Object) IsPointer() bool
- func (object *Object) Raw() map[string]interface{}
- func (object *Object) String(key string) string
- type ObjectRef
- func (ref *ObjectRef) Destroy(authOptions ...AuthOption) error
- func (ref *ObjectRef) Get(object interface{}, authOptions ...AuthOption) error
- func (ref *ObjectRef) Set(key string, value interface{}, authOptions ...AuthOption) error
- func (ref *ObjectRef) Update(diff interface{}, authOptions ...AuthOption) error
- func (ref *ObjectRef) UpdateWithQuery(diff interface{}, query *Query, authOptions ...AuthOption) error
- type Op
- func OpAdd(objects interface{}) Op
- func OpAddRelation(objects interface{}) Op
- func OpAddUnique(objects interface{}) Op
- func OpBitAnd(value interface{}) Op
- func OpBitOr(value interface{}) Op
- func OpBitXor(value interface{}) Op
- func OpDecrement(amount interface{}) Op
- func OpDelete() Op
- func OpIncrement(amount interface{}) Op
- func OpRemove(objects interface{}) Op
- func OpRemoveRelation(objects interface{}) Op
- type ParseResponseError
- type Query
- func (q *Query) And(queries ...*Query) *Query
- func (q *Query) Contains(key, substring string) *Query
- func (q *Query) ContainsAll(key string, objects interface{}) *Query
- func (q *Query) Count(authOptions ...AuthOption) (int, error)
- func (q *Query) EqualTo(key string, value interface{}) *Query
- func (q *Query) Exists(key string) *Query
- func (q *Query) Find(objects interface{}, authOptions ...AuthOption) error
- func (q *Query) First(object interface{}, authOptions ...AuthOption) error
- func (q *Query) GreaterThan(key string, value interface{}) *Query
- func (q *Query) GreaterThanOrEqualTo(key string, value interface{}) *Query
- func (q *Query) In(key string, data interface{}) *Query
- func (q *Query) Include(keys ...string) *Query
- func (q *Query) IncludeACL() *Query
- func (q *Query) LessThan(key string, value interface{}) *Query
- func (q *Query) LessThanOrEqualTo(key string, value interface{}) *Query
- func (q *Query) Limit(limit int) *Query
- func (q *Query) MatchesKeyQuery(key, queryKey string, query *Query) *Query
- func (q *Query) MatchesQuery(key string, query *Query) *Query
- func (q *Query) Near(key string, point *GeoPoint) *Query
- func (q *Query) NotEqualTo(key string, value interface{}) *Query
- func (q *Query) NotExists(key string) *Query
- func (q *Query) NotIn(key string, data interface{}) *Query
- func (q *Query) NotMatchesQuery(key string, query *Query) *Query
- func (q *Query) Or(queries ...*Query) *Query
- func (q *Query) Order(keys ...string) *Query
- func (q *Query) Regexp(key, expr, options string) *Query
- func (q *Query) Select(keys ...string) *Query
- func (q *Query) Skip(count int) *Query
- func (q *Query) StartsWith(key, prefix string) *Query
- func (q *Query) WithinGeoBox(key string, southwest *GeoPoint, northeast *GeoPoint) *Query
- func (q *Query) WithinKilometers(key string, point *GeoPoint) *Query
- func (q *Query) WithinMiles(key string, point *GeoPoint) *Query
- func (q *Query) WithinRadians(key string, point *GeoPoint) *Query
- type RealtimeHookRequest
- type Relation
- type Role
- type RoleRef
- func (ref *RoleRef) Destroy(authOptions ...AuthOption) error
- func (ref *RoleRef) Get(authOption ...AuthOption) (*Role, error)
- func (ref *RoleRef) Set(field string, value interface{}, authOptions ...AuthOption) error
- func (ref *RoleRef) Update(data map[string]interface{}, authOptions ...AuthOption) error
- func (ref *RoleRef) UpdateWithQuery(data map[string]interface{}, authOptions ...AuthOption) error
- type Roles
- type RunOption
- type ServerResponseError
- type User
- type UserRef
- func (ref *UserRef) Destroy(authOptions ...AuthOption) error
- func (ref *UserRef) Get(user interface{}, authOptions ...AuthOption) error
- func (ref *UserRef) Set(key string, value interface{}, authOptions ...AuthOption) error
- func (ref *UserRef) Update(diff interface{}, authOptions ...AuthOption) error
- func (ref *UserRef) UpdateWithQuery(diff interface{}, query *Query, authOptions ...AuthOption) error
- type Users
- func (ref *Users) Become(sessionToken string) (*User, error)
- func (ref *Users) ID(id string) *UserRef
- func (ref *Users) LogIn(username, password string) (*User, error)
- func (ref *Users) LogInByEmail(email, password string) (*User, error)
- func (ref *Users) LogInByMobilePhoneNumber(number, smsCode string) (*User, error)
- func (ref *Users) NewQuery() *Query
- func (ref *Users) RequestEmailVerify(email string, authOptions ...AuthOption) error
- func (ref *Users) RequestLoginSMSCode(number string, authOptions ...AuthOption) error
- func (ref *Users) RequestMobilePhoneVerify(number string, authOptions ...AuthOption) error
- func (ref *Users) RequestPasswordReset(email string, authOptions ...AuthOption) error
- func (ref *Users) RequestPasswordResetBySMSCode(number string, authOptions ...AuthOption) error
- func (ref *Users) ResetPasswordBySMSCode(number, smsCode, password string, authOptions ...AuthOption) error
- func (ref *Users) SignUp(username, password string) (*User, error)
- func (ref *Users) SignUpByEmail(email, password string) (*User, error)
- func (ref *Users) SignUpByMobilePhone(number, smsCode string) (*User, error)
Constants ¶
const Version = "0.3.2"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACL ¶
type ACL struct {
// contains filtered or unexported fields
}
ACL include permission group of object
func NewACLWithUser ¶
func (*ACL) GetPublicReadAccess ¶
func (*ACL) GetPublicWriteAccess ¶
func (*ACL) GetReadAccess ¶
func (*ACL) GetRoleReadAccess ¶
func (*ACL) GetRoleWriteAccess ¶
func (*ACL) GetWriteAccess ¶
func (*ACL) SetPublicReadAccess ¶
func (*ACL) SetPublicWriteAccess ¶
func (*ACL) SetReadAccess ¶
func (*ACL) SetRoleReadAccess ¶
func (*ACL) SetRoleWriteAccess ¶
func (*ACL) SetWriteAccess ¶
type AuthData ¶
type AuthData struct {
// contains filtered or unexported fields
}
func NewAuthData ¶
func NewAuthData() *AuthData
func (*AuthData) SetAnonymous ¶
type AuthOption ¶
type AuthOption interface {
// contains filtered or unexported methods
}
func UseMasterKey ¶
func UseMasterKey(useMasterKey bool) AuthOption
func UseSessionToken ¶
func UseSessionToken(sessionToken string) AuthOption
func UseUser ¶
func UseUser(user *User) AuthOption
type Class ¶
type Class struct { Name string // contains filtered or unexported fields }
func (*Class) Create ¶
func (ref *Class) Create(object interface{}, authOptions ...AuthOption) (*ObjectRef, error)
Create write the Object to the Storage from the custom structure/bare Object/map.
type ClassHookRequest ¶
ClassHookRequest contains object and user passed by Class hook calling
func (*ClassHookRequest) UpdatedKeys ¶
func (r *ClassHookRequest) UpdatedKeys() []string
UpdatedKeys return keys which would be updated, only valid in beforeUpdate hook
type Client ¶
type Client struct { Users Users Files Files Roles Roles // contains filtered or unexported fields }
func NewClient ¶
func NewClient(options *ClientOptions) *Client
NewClient constructs a client from parameters
func NewEnvClient ¶
func NewEnvClient() *Client
NewEnvClient constructs a client from environment variables
func (*Client) RPC ¶ added in v0.3.0
func (client *Client) RPC(name string, params interface{}, results interface{}, runOptions ...RunOption) error
Call cloud function remotely, bind response into `results`
func (*Client) Run ¶ added in v0.3.0
func (client *Client) Run(name string, params interface{}, runOptions ...RunOption) (interface{}, error)
Call cloud funcion remotely
func (*Client) SetProduction ¶ added in v0.3.2
SetProduction sets the production environment
type ClientOptions ¶
type CloudEngine ¶ added in v0.3.0
type CloudEngine interface { Init(client *Client) Handler() http.Handler Run(name string, params interface{}, runOptions ...RunOption) (interface{}, error) RPC(name string, params interface{}, results interface{}, runOptions ...RunOption) error Define(name string, fn func(*FunctionRequest) (interface{}, error), defineOptions ...DefineOption) BeforeSave(class string, fn func(*ClassHookRequest) (interface{}, error)) AfterSave(class string, fn func(*ClassHookRequest) error) BeforeUpdate(class string, fn func(*ClassHookRequest) (interface{}, error)) AfterUpdate(class string, fn func(*ClassHookRequest) error) BeforeDelete(class string, fn func(*ClassHookRequest) (interface{}, error)) AfterDelete(class string, fn func(*ClassHookRequest) error) OnVerified(verifyType string, fn func(*ClassHookRequest) error) OnLogin(fn func(*ClassHookRequest) error) OnIMMessageReceived(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMReceiversOffline(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMMessageSent(fn func(*RealtimeHookRequest) error) OnIMMessageUpdate(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMConversationStart(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMConversationStarted(fn func(*RealtimeHookRequest) error) OnIMConversationAdd(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMConversationRemove(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMConversationAdded(fn func(*RealtimeHookRequest) error) OnIMConversationRemoved(fn func(*RealtimeHookRequest) error) OnIMConversationUpdate(fn func(*RealtimeHookRequest) (interface{}, error)) OnIMClientOnline(fn func(*RealtimeHookRequest) error) OnIMClientOffline(fn func(*RealtimeHookRequest) error) // contains filtered or unexported methods }
var Engine CloudEngine
type CloudError ¶ added in v0.2.0
type CloudError struct { Code int `json:"code"` Message string `json:"error"` StatusCode int `json:"-"` // contains filtered or unexported fields }
CloudError contains user-defined error
func (CloudError) Error ¶ added in v0.2.0
func (err CloudError) Error() string
type DefineOption ¶
type DefineOption interface {
// contains filtered or unexported methods
}
DefineOption apply options for definition of Cloud Function
func WithInternal ¶
func WithInternal() DefineOption
WithInternal restricts that the Cloud Function can only be executed in LeanEngine
func WithoutFetchUser ¶
func WithoutFetchUser() DefineOption
WithoutFetchUser don't fetch current user originated the request
type FileRef ¶
type FileRef struct { ID string // contains filtered or unexported fields }
FileRef refer to a File object in _File class
func (*FileRef) Destroy ¶
func (ref *FileRef) Destroy(authOptions ...AuthOption) error
Destroy delete the referred _File object
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
func (*Files) Upload ¶
func (ref *Files) Upload(file *File, reader io.ReadSeeker, authOptions ...AuthOption) error
Upload transfer the file to cloud storage and create a File object in _File class
func (*Files) UploadFromLocalFile ¶ added in v0.2.0
func (ref *Files) UploadFromLocalFile(file *File, path string, authOptions ...AuthOption) error
UploadFromFile transfer the file given by path to cloud storage and create an object in _File class
func (*Files) UploadFromURL ¶
func (ref *Files) UploadFromURL(file *File, authOptions ...AuthOption) error
UploadFromURL create an object of file in _File class with given file's url
type FunctionRequest ¶
type FunctionRequest struct { Params interface{} CurrentUser *User SessionToken string Meta map[string]string }
FunctionRequest contains request information of Cloud Function
type GeoPoint ¶
GeoPoint contains location's latitude and longitude
func (*GeoPoint) KilometersTo ¶
KilometersTo return the distance from this GeoPoint to another in kilometers
type Object ¶
type Object struct { ID string `json:"objectId"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` // contains filtered or unexported fields }
Object contains full data of Object. Object could also be metadata for custom structure
type ObjectRef ¶
type ObjectRef struct { ID string // contains filtered or unexported fields }
func (*ObjectRef) Destroy ¶
func (ref *ObjectRef) Destroy(authOptions ...AuthOption) error
func (*ObjectRef) Get ¶
func (ref *ObjectRef) Get(object interface{}, authOptions ...AuthOption) error
Get fetchs object from backend
func (*ObjectRef) Set ¶
func (ref *ObjectRef) Set(key string, value interface{}, authOptions ...AuthOption) error
Set manipulate
func (*ObjectRef) Update ¶
func (ref *ObjectRef) Update(diff interface{}, authOptions ...AuthOption) error
func (*ObjectRef) UpdateWithQuery ¶
func (ref *ObjectRef) UpdateWithQuery(diff interface{}, query *Query, authOptions ...AuthOption) error
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
func OpAddRelation ¶
func OpAddRelation(objects interface{}) Op
func OpAddUnique ¶
func OpAddUnique(objects interface{}) Op
func OpDecrement ¶
func OpDecrement(amount interface{}) Op
func OpIncrement ¶
func OpIncrement(amount interface{}) Op
func OpRemoveRelation ¶
func OpRemoveRelation(objects interface{}) Op
type ParseResponseError ¶
type ParseResponseError struct { ParseError error ResponseHeader http.Header ResponseText string StatusCode int URL string }
func (*ParseResponseError) Error ¶
func (err *ParseResponseError) Error() string
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query contain parameters of queries
func (*Query) ContainsAll ¶
func (*Query) Count ¶
func (q *Query) Count(authOptions ...AuthOption) (int, error)
Count returns the count of results of the Query
func (*Query) Find ¶
func (q *Query) Find(objects interface{}, authOptions ...AuthOption) error
Find fetch results of the Query
func (*Query) First ¶
func (q *Query) First(object interface{}, authOptions ...AuthOption) error
First fetch the first result of the Query
func (*Query) GreaterThan ¶
func (*Query) GreaterThanOrEqualTo ¶
func (*Query) IncludeACL ¶
func (*Query) LessThanOrEqualTo ¶
func (*Query) MatchesKeyQuery ¶
func (*Query) NotEqualTo ¶
func (*Query) NotMatchesQuery ¶ added in v0.3.0
func (*Query) StartsWith ¶
func (*Query) WithinGeoBox ¶
func (*Query) WithinKilometers ¶
type RealtimeHookRequest ¶
RealtimeHookRequest contains parameters passed by RTM hook calling
type Relation ¶
type Relation struct {
// contains filtered or unexported fields
}
func NewRelation ¶
type RoleRef ¶
type RoleRef struct { ID string // contains filtered or unexported fields }
func (*RoleRef) Destroy ¶
func (ref *RoleRef) Destroy(authOptions ...AuthOption) error
func (*RoleRef) Set ¶
func (ref *RoleRef) Set(field string, value interface{}, authOptions ...AuthOption) error
func (*RoleRef) Update ¶
func (ref *RoleRef) Update(data map[string]interface{}, authOptions ...AuthOption) error
func (*RoleRef) UpdateWithQuery ¶
func (ref *RoleRef) UpdateWithQuery(data map[string]interface{}, authOptions ...AuthOption) error
type RunOption ¶
type RunOption interface {
// contains filtered or unexported methods
}
RunOption apply options for execution of Cloud Function
func WithSessionToken ¶
WithSessionToken specifics the sessionToken of the calling
type ServerResponseError ¶
type ServerResponseError struct { Code int `json:"code"` Err string `json:"error"` StatusCode int URL string }
func (*ServerResponseError) Error ¶
func (err *ServerResponseError) Error() string
type User ¶
type User struct { Object SessionToken string `json:"sessionToken"` Username string `json:"username"` Email string `json:"email"` EmailVerified bool `json:"emailVerified"` MobilePhoneNumber string `json:"mobilePhoneNumber"` MobilePhoneVerified bool `json:"mobilePhoneVerified"` }
User is a local representation of a user persisted to the LeanCloud server.
type UserRef ¶
type UserRef struct { ID string // contains filtered or unexported fields }
func (*UserRef) Destroy ¶
func (ref *UserRef) Destroy(authOptions ...AuthOption) error
func (*UserRef) Get ¶
func (ref *UserRef) Get(user interface{}, authOptions ...AuthOption) error
func (*UserRef) Set ¶
func (ref *UserRef) Set(key string, value interface{}, authOptions ...AuthOption) error
func (*UserRef) Update ¶
func (ref *UserRef) Update(diff interface{}, authOptions ...AuthOption) error
func (*UserRef) UpdateWithQuery ¶
func (ref *UserRef) UpdateWithQuery(diff interface{}, query *Query, authOptions ...AuthOption) error
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
func (*Users) LogInByEmail ¶ added in v0.2.0
func (*Users) LogInByMobilePhoneNumber ¶
func (*Users) RequestEmailVerify ¶
func (ref *Users) RequestEmailVerify(email string, authOptions ...AuthOption) error
func (*Users) RequestLoginSMSCode ¶
func (ref *Users) RequestLoginSMSCode(number string, authOptions ...AuthOption) error
func (*Users) RequestMobilePhoneVerify ¶
func (ref *Users) RequestMobilePhoneVerify(number string, authOptions ...AuthOption) error
func (*Users) RequestPasswordReset ¶
func (ref *Users) RequestPasswordReset(email string, authOptions ...AuthOption) error
func (*Users) RequestPasswordResetBySMSCode ¶
func (ref *Users) RequestPasswordResetBySMSCode(number string, authOptions ...AuthOption) error
func (*Users) ResetPasswordBySMSCode ¶
func (ref *Users) ResetPasswordBySMSCode(number, smsCode, password string, authOptions ...AuthOption) error