sync

package
v0.0.0-...-3bcc4b6 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is a local representation of a Firebase database.

func NewDB

func NewDB() *Database

NewDB creates a new instance of a Database.

func (*Database) Add

func (d *Database) Add(path string, n *Node)

Add puts a Node into the database.

func (*Database) Del

func (d *Database) Del(path string)

Del removes the node at the given path.

func (*Database) Get

func (d *Database) Get(path string) *Node

Get fetches a node at a given path.

func (*Database) Update

func (d *Database) Update(path string, n *Node)

Update merges the current node with the given node.

type Node

type Node struct {
	Key      string
	Value    interface{}
	Children map[string]*Node

	Parent *Node
	// contains filtered or unexported fields
}

Node represents an object linked in Database. This object should not be created by hand, use NewNode when creating a new instance of Node.

func NewNode

func NewNode(key string, data interface{}) *Node

NewNode converts the given data into a node.

func (*Node) Child

func (n *Node) Child(name string) (*Node, bool)

Child gets a DataSnapshot for the location at the specified relative path. The relative path can either be a simple child key (e.g. 'fred') or a deeper slash-separated path (e.g. 'fred/name/first').

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

MarshalJSON turns the node object into JSON bytes.

func (*Node) Objectify

func (n *Node) Objectify() interface{}

Objectify turns the node and all its children into a go type. If a node was created from a slice initially, a slice will be return. If a node has child nodes, a map will be returned. Otherwise, a primitive type will be returned.

Jump to

Keyboard shortcuts

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