func (c *RecordsCommand) runCount() int { k, err := stringInput(c.UI, "Which kind?") if err != nil { return failure } results, err := c.DBClient.Query(context.Background(), &data.Query{ Kind: models.Kind(models.Kind_value[strings.ToUpper(k)]), }) if err != nil { return failure } n := 0 for { _, err := results.Recv() if err == io.EOF { break } if err != nil { return failure } n++ } c.UI.Output(fmt.Sprintf("%d", n)) return success }
func (c *RecordsCommand) runChanges() int { k, err := stringInput(c.UI, "Which kind?") if err != nil { return failure } results, err := c.DBClient.Changes(context.Background(), &data.Query{ Kind: models.Kind(models.Kind_value[strings.ToUpper(k)]), }) if err != nil { return failure } for { r, err := results.Recv() if err == io.EOF { break } if err != nil { return failure } c.UI.Output(fmt.Sprintf("%v", r)) } c.UI.Output("stream closed by server") return success }