-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsnapshots.go
46 lines (37 loc) · 980 Bytes
/
snapshots.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package firebase
import (
"bytes"
"encoding/json"
)
// DataSnapshot type
type DataSnapshot struct {
ref *Reference
raw []byte
}
// Key returns the location of this DataSnapshot
func (snapshot *DataSnapshot) Key() string {
panic(ErrNotImplemented)
}
// Ref returns the Reference for the location generated this DataSnapshot
func (snapshot *DataSnapshot) Ref() *Reference {
return snapshot.ref
}
// Exists returns true if this DataSnapshot contains any data
func (snapshot *DataSnapshot) Exists() bool {
return bytes.Compare(snapshot.raw, []byte("null")) != 0
}
// Val extracts a value from a DataSnapshot
func (snapshot *DataSnapshot) Val(v interface{}) error {
return json.NewDecoder(bytes.NewReader(snapshot.raw)).Decode(v)
}
// Bytes returns snapshot raw data
func (snapshot *DataSnapshot) Bytes() []byte {
return snapshot.raw
}
// ChildSnapshot type
type ChildSnapshot struct {
PrevChildKey string
}
// OldChildSnapshot type
type OldChildSnapshot struct {
}