All Projects → zabawaba99 → Firego

zabawaba99 / Firego

Licence: mit
Firebase Go Client

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Firego

React Native Firebase Starter
The ultimate React Native starter using Firebase, Mobx, CodePush, OneSignal made with ♥
Stars: ✭ 289 (-15.74%)
Mutual labels:  firebase
Firebasepushnotificationplugin
Firebase Push Notification Plugin for Xamarin iOS and Android
Stars: ✭ 307 (-10.5%)
Mutual labels:  firebase
Sapphiredb
SapphireDb Server, a self-hosted, easy to use realtime database for Asp.Net Core and EF Core
Stars: ✭ 326 (-4.96%)
Mutual labels:  firebase
Internalappstore
📦 Manage your own internal Android App Store.
Stars: ✭ 295 (-13.99%)
Mutual labels:  firebase
Firestore Backup Restore
NPM package for backup and restore Firebase Firestore
Stars: ✭ 307 (-10.5%)
Mutual labels:  firebase
Devlopr Jekyll
Build and Deploy your Static Site 🚀 using this beautiful Jekyll Framework/Theme built for Creatives
Stars: ✭ 309 (-9.91%)
Mutual labels:  firebase
Firebase Cms
A CMS + E-commerce platform built with Angular and Firebase
Stars: ✭ 286 (-16.62%)
Mutual labels:  firebase
Firebase Js Sdk
Firebase Javascript SDK
Stars: ✭ 3,844 (+1020.7%)
Mutual labels:  firebase
Flutter programs
Experiments with Mobile
Stars: ✭ 308 (-10.2%)
Mutual labels:  firebase
Awesome Flutter Talks
A list of Flutter related talks
Stars: ✭ 324 (-5.54%)
Mutual labels:  firebase
Flutter Firebase Quizapp Course
QuizApp Built with Flutter & Firebase
Stars: ✭ 301 (-12.24%)
Mutual labels:  firebase
Firesql
Query Firestore using SQL syntax
Stars: ✭ 304 (-11.37%)
Mutual labels:  firebase
Mechahamster
Mecha Hamster is a game where you roll through customizable environments that you can share with your friends.
Stars: ✭ 314 (-8.45%)
Mutual labels:  firebase
Squanchy Android
Open source Android app for your conferences
Stars: ✭ 294 (-14.29%)
Mutual labels:  firebase
React Redux Firebase Boilerplate
🔥 🚀 React, Redux, Firebase Boilerplate
Stars: ✭ 326 (-4.96%)
Mutual labels:  firebase
Clean Mvvm Archcomponents
👽 Android app consuming Star Wars API.Built with clean architecture ,MVVM pattern, Koin , Coroutines + Flows ,Architecture Components, Data Binding , Firebase , Unit/UI Tests ,Motion Layout
Stars: ✭ 285 (-16.91%)
Mutual labels:  firebase
Falconmessenger
🌟🌟🌟🌟🌟 Falcon Messenger is a Fast and Beautiful cloud-based messaging app. With iOS and IPadOS Support. Available on the App Store.
Stars: ✭ 310 (-9.62%)
Mutual labels:  firebase
Vuetify Chat
A chat built with Vue + Vuex + Vuetify + Firebase
Stars: ✭ 338 (-1.46%)
Mutual labels:  firebase
Magicprint Ecommerce App Android
E-Commerce App Source Code for Android with Material Design Pattern Using Firebase and MySQL with Android Lottie Animations just like Flipkart, Myntra and Amazon :)
Stars: ✭ 331 (-3.5%)
Mutual labels:  firebase
Firebase Mock
Firebase mock library for writing unit tests
Stars: ✭ 319 (-7%)
Mutual labels:  firebase

Firego

Deprecated in favor of firebase/firebase-admin-go.


Build Status Coverage Status

A Firebase client written in Go

Installation

go get -u gopkg.in/zabawaba99/firego.v1

Usage

Import firego

import "gopkg.in/zabawaba99/firego.v1"

Create a new firego reference

f := firego.New("https://my-firebase-app.firebaseIO.com", nil)

with existing http client

f := firego.New("https://my-firebase-app.firebaseIO.com", client)

Request Timeouts

By default, the Firebase reference will timeout after 30 seconds of trying to reach a Firebase server. You can configure this value by setting the global timeout duration

firego.TimeoutDuration = time.Minute

Authentication

You can authenticate with your service_account.json file by using the golang.org/x/oauth2 package (thanks @m00sey for the snippet)

d, err := ioutil.ReadFile("our_service_account.json")
if err != nil {
    return nil, err
}

conf, err := google.JWTConfigFromJSON(d, "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/firebase.database")
if err != nil {
    return nil, err
}

fb := firego.New("https://you.firebaseio.com", conf.Client(oauth2.NoContext))
// use the authenticated fb instance

Legacy Tokens

f.Auth("some-token-that-was-created-for-me")
f.Unauth()

Visit Fireauth if you'd like to generate your own auth tokens

Get Value

var v map[string]interface{}
if err := f.Value(&v); err != nil {
  log.Fatal(err)
}
fmt.Printf("%s\n", v)

Querying

Take a look at Firebase's query parameters for more information on what each function does.

var v map[string]interface{}
if err := f.StartAt("a").EndAt("c").LimitToFirst(8).OrderBy("field").Value(&v); err != nil {
	log.Fatal(err)
}
fmt.Printf("%s\n", v)

Set Value

v := map[string]string{"foo":"bar"}
if err := f.Set(v); err != nil {
  log.Fatal(err)
}

Push Value

v := "bar"
pushedFirego, err := f.Push(v)
if err != nil {
	log.Fatal(err)
}

var bar string
if err := pushedFirego.Value(&bar); err != nil {
	log.Fatal(err)
}

// prints "https://my-firebase-app.firebaseIO.com/-JgvLHXszP4xS0AUN-nI: bar"
fmt.Printf("%s: %s\n", pushedFirego, bar)

Update Child

v := map[string]string{"foo":"bar"}
if err := f.Update(v); err != nil {
  log.Fatal(err)
}

Remove Value

if err := f.Remove(); err != nil {
  log.Fatal(err)
}

Watch a Node

notifications := make(chan firego.Event)
if err := f.Watch(notifications); err != nil {
	log.Fatal(err)
}

defer f.StopWatching()
for event := range notifications {
	fmt.Printf("Event %#v\n", event)
}
fmt.Printf("Notifications have stopped")

Change reference

You can use a reference to save or read data from a specified reference

userID := "bar"
usersRef,err := f.Ref("users/"+userID)
if err != nil {
  log.Fatal(err)
}
v := map[string]string{"id":userID}
if err := usersRef.Set(v); err != nil {
  log.Fatal(err)
}

Check the GoDocs or Firebase Documentation for more details

Running Tests

In order to run the tests you need to go get -t ./... first to go-get the test dependencies.

Issues Management

Feel free to open an issue if you come across any bugs or if you'd like to request a new feature.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Some cool reflection')
  4. Push to the branch (git push origin new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].