formatTypes takes a list of TypeUpdates and converts them in to a list of maps in a format that is human-readable to be marshaled into JSON.
(typeList []*pb.TypeUpdate)
| 2409 | // formatTypes takes a list of TypeUpdates and converts them in to a list of |
| 2410 | // maps in a format that is human-readable to be marshaled into JSON. |
| 2411 | func formatTypes(typeList []*pb.TypeUpdate) []map[string]interface{} { |
| 2412 | var res []map[string]interface{} |
| 2413 | for _, typ := range typeList { |
| 2414 | typeMap := make(map[string]interface{}) |
| 2415 | typeMap["name"] = typ.TypeName |
| 2416 | fields := make([]map[string]string, len(typ.Fields)) |
| 2417 | |
| 2418 | for i, field := range typ.Fields { |
| 2419 | m := make(map[string]string, 1) |
| 2420 | m["name"] = field.Predicate |
| 2421 | fields[i] = m |
| 2422 | } |
| 2423 | typeMap["fields"] = fields |
| 2424 | |
| 2425 | res = append(res, typeMap) |
| 2426 | } |
| 2427 | return res |
| 2428 | } |
| 2429 | |
| 2430 | func isDropAll(op *api.Operation) bool { |
| 2431 | if op.DropAll || op.DropOp == api.Operation_ALL { |