fsc

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2019 License: Apache-2.0 Imports: 17 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Datastore Connectivity for Firestore (fsc)

Datastore Connectivity library for Firebase in Go. GoDoc

This library is compatible with Go 1.10+

Please refer to CHANGELOG.md if you encounter breaking changes.

Usage:

The following is a very simple example of CRUD operations

package main

import (
	"github.com/viant/dsc"
	"log"
    _ "github.com/adrianwit/fsc"
)


type User struct {
	Id int	
	Name string
}


func main() {

    credentials := "secrets.json"
	config, err := dsc.NewConfigWithParameters("fsc", "", credentials, map[string]interface{}{
		// specify databaseURL to use console.firebase.google.com scoped firestore, 
		// otherwise it would use console.cloud.google.com/firestore
		"databaseURL":   databaseURL, 
 		"projectID":     projectID,
 	})
	
	
	if err != nil {
		log.Fatal(err)
    }
	factory := dsc.NewManagerFactory()
	manager, err := factory.Create(config)
    if err != nil {
    	log.Fatal(err)
    }
    }
    
    var users []*User; // 
   
	inserted, updated, err:= manager.PersistAll(&users, "users", nil)
	if err != nil {
       log.Fatal(err)
   	}

    
    err:= manager.ReadAll(&users, "SELECT id, name FROM users WHERE id IN(?, ?)", []interface{}{1, 10},nil)
	 if err != nil {
         log.Fatal(err)
     }

   
  
    deleted, err := manager.DeleteAll(&users, "users", nil)
    if err != nil {
        log.Fatal(err)
   	}
  
}

License

The source code is made available under the terms of the Apache License, Version 2, as stated in the file LICENSE.

Individual files may be made available under their own specific license, all compatible with Apache License, Version 2. Please see individual files for details.

Credits and Acknowledgements

Library Author: Adrian Witas

Contributors:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppPointerKey = (*firebase.App)(nil)

AppPointer represents an app pointer context key

View Source
var ClientPointerKey = (*firestore.Client)(nil)

ClientPointerKey represents an client pointer key

View Source
var ContextPointerKey = (*context.Context)(nil)

ClientPointerKey represents an context pointer key

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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