Skip to content

kylemcc/parse

Repository files navigation

#Parse

Godoc license

This package provides a client for Parse's REST API. So far, it supports most of the query operations provided by Parse's Javascript library, with a few exceptions (listed below under TODO).

###Installation

go get github.com/kylemcc/parse

###Documentation Full documentation is provided by godoc.org

###Usage:

package main

import (
    "fmt"
	"time"
    
    "github.com/kylemcc/parse"
)

func main() {
    parse.Initialize("APP_ID", "REST_KEY", "MASTER_KEY") // master key is optional
    
    user := parse.User{}
    q, err := parse.NewQuery(&user)
	if err != nil {
		panic(err)
	}
    q.EqualTo("email", "[email protected]")
    q.GreaterThan("numFollowers", 10).OrderBy("-createdAt") // API is chainable
    err := q.First()
    if err != nil {
        if pe, ok := err.(parse.ParseError); ok {
            fmt.Printf("Error querying parse: %d - %s\n", pe.Code(), pe.Message())
        }
    }
    
    fmt.Printf("Retrieved user with id: %s\n", u.Id)

	q2, _ := parse.NewQuery(&parse.User{})
	q2.GreaterThan("createdAt", time.Date(2014, 01, 01, 0, 0, 0, 0, time.UTC))
	rc := make(chan *parse.User)
	ec := make(chan error)

	// .Each will retrieve all results for a query and send them to the provided channel
	q2.Each(rc, ec, nil)
	for {
		select {
		case u, ok := <-rc:
			if ok {
				fmt.Printf("received user: %v\n", u)
			} else {
				rc = nil
			}
		case err, ok := <-ec:
			if ok {
				fmt.Printf("error: %v\n", err)
			} else {
				ec = nil
			}
		}
		if rc == nil && ec == nil {
			break
		}
	}
}

###TODO

  • Missing query operations
    • Related to
  • Missing CRUD operations:
    • Update
      • Field ops (__op):
        • AddRelation
        • RemoveRelation
  • Roles
  • Cloud Functions
  • Background Jobs
  • Analytics
  • File upload/retrieval
  • Batch operations

About

Parse.com API Client Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages