Giter Site home page Giter Site logo

parse-go's Introduction

parse-go

Parse.com API Client Library

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/ihoukai/parse-go

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

###Usage:

package main

import (
	"fmt"
	"time"

	parse "github.com/ihoukai/parse-go"
)

func main() {
	parse.Initialize(&parse.ClientConfig{
		Schema:     parse.SchemeHttp,
		Host:       "192.168.0.122:1337",
		PathPrefix: "/parse",
		Version:    "",
		AppID:      "myAppId",
		RestKey:    "restAPIKey",
		MasterKey:  "myAppId", // 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)

	// .Each will retrieve all results for a query and send them to the provided channel
	// The iterator returned allows for early cancelation of the iteration process, and
	// stores any error that triggers early termination
	iterator, err := q2.Each(rc)
	for u := range rc {
		fmt.Printf("received user: %v\n", u)
		// Do something
		if err := process(u); err != nil {
			// Cancel if there was an error
			iterator.Cancel()
		}
	}

	// An error occurred - not all rows were processed
	if it.Error() != nil {
		panic(it.Error())
	}
}

###TODO

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

parse-go's People

Contributors

ihoukai avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

pmsl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.