-
Notifications
You must be signed in to change notification settings - Fork 0
/
document_meta.go
78 lines (62 loc) · 2.36 KB
/
document_meta.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package streams
import "github.com/benpate/rosetta/mapof"
/******************************************
* Metadata Getters
******************************************/
// Meta returns a pointer to the metadata associated with this document.
func (document Document) Meta() *mapof.Any {
return &document.metadata
}
// MetaBool returns a bool from the document's metadata.
func (document Document) MetaBool(name string) bool {
return document.metadata.GetBool(name)
}
// MetaFloat returns a float64 from the document's metadata.
func (document Document) MetaFloat(name string) float64 {
return document.metadata.GetFloat(name)
}
// MetaInt returns an int from the document's metadata.
func (document Document) MetaInt(name string) int {
return document.metadata.GetInt(name)
}
// MetaInt64 returns an int64 from the document's metadata.
func (document Document) MetaInt64(name string) int64 {
return document.metadata.GetInt64(name)
}
// MetaString returns a string from the document's metadata.
func (document Document) MetaString(name string) string {
return document.metadata.GetString(name)
}
/******************************************
* Metadata Setters
******************************************/
// MetaSet replaces the metadata associated with this document.
func (document *Document) MetaSet(value mapof.Any) {
document.metadata = value
}
// MetaAdd adds the specified metadata to the document.
func (document *Document) MetaAdd(value mapof.Any) {
for key, value := range value {
document.metadata[key] = value
}
}
// MetaSetBool sets a bool value in the document's metadata.
func (document *Document) MetaSetBool(name string, value bool) {
document.metadata.SetBool(name, value)
}
// MetaSetFloat sets a float64 value in the document's metadata.
func (document *Document) MetaSetFloat(name string, value float64) {
document.metadata.SetFloat(name, value)
}
// MetaSetInt sets an int value in the document's metadata.
func (document *Document) MetaSetInt(name string, value int) {
document.metadata.SetInt(name, value)
}
// MetaSetInt64 sets an int64 value in the document's metadata.
func (document *Document) MetaSetInt64(name string, value int64) {
document.metadata.SetInt64(name, value)
}
// MetaSetString sets a string value in the document's metadata.
func (document *Document) MetaSetString(name string, value string) {
document.metadata.SetString(name, value)
}