GithubHelp home page GithubHelp logo

admin_client's Introduction

Singleton Firebase Admin Client

Install:

go get -u github.com/ClassFunc/admin_client

Usage:

package main

import (
    "github.com/ClassFunc/admin_client"
)

func main() {

    admin_client.New(
    "PROJECT_ID",
    "SERVICE_ACCOUNT_FILE_PATH",
    )
    // or more simpler
    admin_client.WithCredentialsFile("SERVICE_ACCOUNT_FILE_PATH")
    
    // then you can use
    admin_client.DB.Collection(...)
    admin_client.Auth.CreateUser(...)
    admin_client.DefaultBucket.Object("media/" + fileName)
    admin_client.Storage.Bucket("name").Object("media/" + fileName)
	
	
    // settings firestore client
    admin_client.EnvCollPrefix = "GO_COL_"
    fmt.Println(admin_client.CollPathFromEnv("GO_COL_USERS"))
    
    // actions with firestore collections
    admin_client.CollRef("GO_COL_USERS" /* or "users"*/)
    admin_client.CollGetAllDocs("users")
    admin_client.CollGetAllDocsData("users")
    
    // actions with firestore documents
    admin_client.DocRef("users", "123")
    admin_client.GetDoc("users", "123")
    admin_client.GetDocData("users", "123")
    admin_client.GetDocDataTo("users", "123", nil)
    
    // actions with firestore sub_collections
    admin_client.SubCollRef("users", "123", "roles")
    admin_client.SubCollGetAllDocs("users", "123", "roles")
    admin_client.SubCollGetAllDocsData("users", "123", "roles")
    
    // actions with firestore sub_documents
    admin_client.SubDocRef("users", "123", "roles", "456")
    admin_client.GetSubDoc("users", "123", "roles", "456")
    admin_client.GetSubDocData("users", "123", "roles", "456")

	type User struct {
        Name string
    }
    var adam = new(User)
    admin_client.GetDocDataTo("users", "123", adam)
}

Lisence:

MIT

Authors:

ClassFunc Softwares JSC

Website: https://classfunc.com

admin_client's People

Contributors

lhphongclassfunc avatar zerolethanh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.