firebase

package module
v0.0.0-...-39a1854 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2017 License: MIT Imports: 8 Imported by: 2

README

firebase

A Go package for the Firebase API #golang

Installation

Install the package with go:

go get github.com/melvinmt/firebase

And add it to your go file:

package name

import (
    "github.com/melvinmt/firebase"
)

Usage

package main

import (
    "github.com/melvinmt/firebase"
    "fmt"
)

type PersonName struct {
    First string
    Last  string
}

type Person struct {
    Name PersonName
}

func main() {
    var err error

    url := "https://SampleChat.firebaseIO-demo.com/users/fred/name"

    // Can also be your Firebase secret:
    authToken := "MqL0c8tKCtheLSYcygYNtGhU8Z2hULOFs9OKPdEp"

    // Auth is optional:
    ref := firebase.NewReference(url).Auth(authToken)

    // Create the value.
    personName := PersonName{
        First: "Fred",
        Last:  "Swanson",
    }

    // Write the value to Firebase.
    if err = ref.Write(personName); err != nil {
        panic(err)
    }

    // Now, we're going to retrieve the person.
    personUrl := "https://SampleChat.firebaseIO-demo.com/users/fred"

    personRef := firebase.NewReference(personUrl).Export(false)

    fred := Person{}

    if err = personRef.Value(fred); err != nil {
        panic(err)
    }

    fmt.Println(fred.Name.First, fred.Name.Last) // prints: Fred Swanson
}

Docs

http://godoc.org/github.com/melvinmt/firebase

Documentation

Overview

A Go package for the Firebase API #golang

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reference

type Reference struct {
	Client client
	// contains filtered or unexported fields
}

func NewReference

func NewReference(url string) *Reference

Retrieve a new Firebase reference for given url.

func (*Reference) Auth

func (r *Reference) Auth(token string) *Reference

Uses the Firebase secret or Auth Token to authenticate.

func (*Reference) Delete

func (r *Reference) Delete() error

Delete any values for this Reference.

func (*Reference) Export

func (r *Reference) Export(toggle bool) *Reference

Set to true if you want priority data to be returned.

func (*Reference) Push

func (r *Reference) Push(v interface{}) error

Pushes a new object to this Reference (effectively creates a list).

func (*Reference) Update

func (r *Reference) Update(v interface{}) error

Update existing data.

func (*Reference) Value

func (r *Reference) Value(v interface{}) error

Retrieve the current value for this Reference.

func (*Reference) Write

func (r *Reference) Write(v interface{}) error

Set the value for this Reference (overwrites existing value).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL