mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
add options.keys and lowercase names to json output
This commit is contained in:
parent
785bcde7d0
commit
9305712237
2 changed files with 19 additions and 10 deletions
14
field.go
14
field.go
|
|
@ -1094,9 +1094,9 @@ func (f *Field) ImportValue(columnIDs []uint64, values []int64) error {
|
|||
|
||||
func (f *Field) MarshalJSON() ([]byte, error) {
|
||||
thing := struct {
|
||||
Name string
|
||||
Options FieldOptions
|
||||
Views []*ViewInfo
|
||||
Name string `json:"name"`
|
||||
Options FieldOptions `json:"options"`
|
||||
Views []*ViewInfo `json:"views"`
|
||||
}{
|
||||
Name: f.Name(),
|
||||
Options: f.Options(),
|
||||
|
|
@ -1134,7 +1134,7 @@ type FieldOptions struct {
|
|||
Min int64 `json:"min,omitempty"`
|
||||
Max int64 `json:"max,omitempty"`
|
||||
TimeQuantum TimeQuantum `json:"timeQuantum,omitempty"`
|
||||
Keys bool `json:"keys,omitempty"`
|
||||
Keys bool `json:"keys"`
|
||||
}
|
||||
|
||||
// applyDefaultOptions returns a new FieldOptions object
|
||||
|
|
@ -1177,28 +1177,34 @@ func (o *FieldOptions) MarshalJSON() ([]byte, error) {
|
|||
Type string `json:"type"`
|
||||
CacheType string `json:"cacheType"`
|
||||
CacheSize uint32 `json:"cacheSize"`
|
||||
Keys bool `json:"keys"`
|
||||
}{
|
||||
o.Type,
|
||||
o.CacheType,
|
||||
o.CacheSize,
|
||||
o.Keys,
|
||||
})
|
||||
case FieldTypeInt:
|
||||
return json.Marshal(struct {
|
||||
Type string `json:"type"`
|
||||
Min int64 `json:"min"`
|
||||
Max int64 `json:"max"`
|
||||
Keys bool `json:"keys"`
|
||||
}{
|
||||
o.Type,
|
||||
o.Min,
|
||||
o.Max,
|
||||
o.Keys,
|
||||
})
|
||||
case FieldTypeTime:
|
||||
return json.Marshal(struct {
|
||||
Type string `json:"type"`
|
||||
TimeQuantum TimeQuantum `json:"timeQuantum"`
|
||||
Keys bool `json:"keys"`
|
||||
}{
|
||||
o.Type,
|
||||
o.TimeQuantum,
|
||||
o.Keys,
|
||||
})
|
||||
}
|
||||
return nil, errors.New("invalid field type")
|
||||
|
|
|
|||
15
index.go
15
index.go
|
|
@ -83,11 +83,13 @@ func (i *Index) MarshalJSON() ([]byte, error) {
|
|||
fields = append(fields, f)
|
||||
}
|
||||
thing := struct {
|
||||
Name string
|
||||
Fields []*Field
|
||||
Name string `json:"name"`
|
||||
Options IndexOptions `json:"options"`
|
||||
Fields []*Field `json:"fields"`
|
||||
}{
|
||||
Name: i.name,
|
||||
Fields: fields,
|
||||
Name: i.name,
|
||||
Options: i.Options(),
|
||||
Fields: fields,
|
||||
}
|
||||
return json.Marshal(thing)
|
||||
}
|
||||
|
|
@ -422,8 +424,9 @@ func (p indexSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() }
|
|||
|
||||
// IndexInfo represents schema information for an index.
|
||||
type IndexInfo struct {
|
||||
Name string `json:"name"`
|
||||
Fields []*FieldInfo `json:"fields"`
|
||||
Name string `json:"name"`
|
||||
Options IndexOptions `json:"options"`
|
||||
Fields []*FieldInfo `json:"fields"`
|
||||
}
|
||||
|
||||
type indexInfoSlice []*IndexInfo
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue