/go-parse

a parse.com rest api client library

Primary LanguageGoMIT LicenseMIT

go-parse

a parse.com REST API client library for go

install

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

quick usage

  1. config client:
	var parseClient = parse.NewClient()
	parseClient.AppId = ""
	parseClient.AppKey = ""
	parseClient.DebugRequest = true
  1. Object CRUD
className := "TestClass"
o := parse.NewObject()
o.Set("key", "value")
fetchOnSave := true
o.Create(parseClient, className, fetchOnSave)

o.Set("newKey", "newValue")
o.Update(parseClient, className)

o2 := parse.NewObject()
oid := o.ObjectId()
o2.Fetch(parseClient, className, oid, "")

o2.Delete(parseClient, className)
  1. call cloud function:
param := parse.NewParams()
param["key"] = "value"
ret, err := parseClient.CallFunction("functionName", param.Encode())
  1. query objects (basic)
	opt := QueryOptions{
		Class:   "PS",
		Limit:   DefaultLimit,
		Skip:    0,
		Order:   "-createdAt'",
		Keys:    "",
		Include: "",
		Count:   false,
	}
	r, err := QueryObjects(parseClient, opt)
	if err != nil {
		t.Fatal(err)
	}
	objs, _ := r.GetResults()
	for _, o := range objs {
		t.Log(o.ObjectId())
	}
  1. query objects (advance)
	where := NewWhere()
	where.AddEqualTo("objectId", "abcd")
	where.Add("someKey", OpLessThanOrEqualTo, 100)
	opt := QueryOptions{
		Class:   "PS",
		Limit:   DefaultLimit,
		Skip:    0,
		Order:   "-createdAt'",
		Keys:    "",
		Include: "",
		Count:   false,
		Where:   where,
	}
	r, err := QueryObjects(parseClient, opt)
	if err != nil {
		t.Fatal(err)
	}
	objs, _ := r.GetResults()
	for _, o := range objs {
		t.Log(o.ObjectId())
	}

API doc

see doc

examples

see test