-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.go
54 lines (43 loc) · 948 Bytes
/
schema.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
package schema
import (
"encoding/json"
)
type DataType string
//Column data goes here
type Column struct {
Name string
Type DataType
}
// Source is a path reference to datafile
type Source string
//
type InfoDef struct{ Name, Description, Url string }
type Table struct {
Sources []Source
Columns map[string]Column
}
type Slice struct {
Table string
Dimensions []string
Metrics []string
}
//implements https://github.com/cfpb/qu/wiki/Dataset-publishing-format
type Definition struct {
Info InfoDef
Tables map[string]Table
Slices map[string]Slice
}
// Makes an empty Definintion
func NewDefinition() *Definition {
var definition = new(Definition)
return definition
}
//Serialize a Definition to Json
func (d *Definition) ToJson() []byte {
data, _ := json.Marshal(&d)
return data
}
//Inflate a Definition from a json representation
func (d *Definition) FromJson(jsondata []byte) {
json.Unmarshal(jsondata, &d)
}