mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
exclude views from http schema output
This commit is contained in:
parent
9305712237
commit
c10cdc9d22
3 changed files with 20 additions and 4 deletions
6
api.go
6
api.go
|
|
@ -482,9 +482,9 @@ func (api *API) ClusterMessage(ctx context.Context, reqBody io.Reader) error {
|
|||
}
|
||||
|
||||
// Schema returns information about each index in Pilosa including which fields
|
||||
// and views they contain.
|
||||
func (api *API) Schema(ctx context.Context) []*Index {
|
||||
return api.holder.Indexes()
|
||||
// they contain.
|
||||
func (api *API) Schema(ctx context.Context) []*IndexInfo {
|
||||
return api.holder.limitedSchema()
|
||||
}
|
||||
|
||||
// Views returns the views in the given field.
|
||||
|
|
|
|||
16
holder.go
16
holder.go
|
|
@ -228,6 +228,22 @@ func (h *Holder) Schema() []*IndexInfo {
|
|||
return a
|
||||
}
|
||||
|
||||
// limitedSchema returns schema information for all indexes and fields.
|
||||
func (h *Holder) limitedSchema() []*IndexInfo {
|
||||
var a []*IndexInfo
|
||||
for _, index := range h.Indexes() {
|
||||
di := &IndexInfo{Name: index.Name()}
|
||||
for _, field := range index.Fields() {
|
||||
fi := &FieldInfo{Name: field.Name(), Options: field.Options()}
|
||||
di.Fields = append(di.Fields, fi)
|
||||
}
|
||||
sort.Sort(fieldInfoSlice(di.Fields))
|
||||
a = append(a, di)
|
||||
}
|
||||
sort.Sort(indexInfoSlice(a))
|
||||
return a
|
||||
}
|
||||
|
||||
// applySchema applies an internal Schema to Holder.
|
||||
func (h *Holder) applySchema(schema *Schema) error {
|
||||
// Create indexes that don't exist.
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ func (h *Handler) handleGetIndex(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
indexName := mux.Vars(r)["index"]
|
||||
for _, idx := range h.API.Schema(r.Context()) {
|
||||
if idx.Name() == indexName {
|
||||
if idx.Name == indexName {
|
||||
if err := json.NewEncoder(w).Encode(idx); err != nil {
|
||||
h.Logger.Printf("write response error: %s", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue