-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.go
29 lines (25 loc) · 636 Bytes
/
data.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
package mongotest
// DocData is document data
// key: field name
// value: field value
type DocData map[string]interface{}
// StringValue returns value of given key as string.
func (d DocData) StringValue(key string) (string, bool) {
v, ok := d[key]
if !ok {
return "", false
}
s, ok := v.(string)
if !ok {
return "", false
}
return s, true
}
// CollectionData is collection data
// key: document ID
// value: document data (exclude ID)
type CollectionData map[string]DocData
// DataSet is collection of collection data
// key: collection name
// value: collection data
type DataSet map[string]CollectionData