Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-leancloud

a leancloud REST API client library for go

install

go get -u github.com/zx9597446/go-leancloud

quick usage

  1. config client:
var client = &leancloud.Client{}
cfg := leancloud.Config{}
cfg.AppId = ""
cfg.AppKey = ""
cfg.MasterKey = ""
cfg.UsingMaster = true
client.Cfg = cfg
  1. Object CRUD
className := "TestClass"
o := leancloud.NewObject()
o.Set("key", "value")
fetchOnSave := true
o.Save(client, className, fetchOnSave)

o.Set("newKey", "newValue")
o.Update(client, className)
o.Delete(client, className)

obj, err := leancloud.FetchObject(client, className, objectId, include)

leancloud.DeleteObject(client, className, objectId)
  1. call leancloud function:
param := leancloud.NewParams()
param["key"] = "value"
ret, err := leancloud.CallFunction(client, "functionName", param.Encode())
  1. execute CQL:
//ret is a map["result"]={obj1, obj2...}
ret, err := leancloud.CQLf(client, "select * from _User where username like '%s' limit 1", "abc")

//to retrive all objects in ret, using this:
objects, err := ret.GetResults()

//to retrive one single object in ret, using this:
object, err := ret.GetResultByIdx(idx)
  1. call leancloud function(or object CRUD) with SessionToken:
ret, err := leancloud.CallFunction(client.WithSessionToken(""), fn", "param")
  1. dump http request:
	client.BeforeRequest = func(r *http.Request) *http.Request {
		//data, _ := httputil.DumpRequestOut(r, true)
		//log.Println(string(data))
		return r
	}

API doc

see doc

examples

see test

About

a leancloud go client library

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages