Skip to content

Commit

Permalink
Add show collection by name (#120)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Mar 24, 2023
1 parent b765db7 commit f39c6ae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion states/etcd/show/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func CollectionCommand(cli clientv3.KV, basePath string) *cobra.Command {
fmt.Println(err.Error())
return
}
collectionName, err := cmd.Flags().GetString("name")
if err != nil {
fmt.Println(err.Error())
return
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -40,7 +45,10 @@ func CollectionCommand(cli clientv3.KV, basePath string) *cobra.Command {
collections = append(collections, collection)
}
} else {
collections, err = common.ListCollectionsVersion(ctx, cli, basePath, etcdversion.GetVersion(), func(_ *models.Collection) bool {
collections, err = common.ListCollectionsVersion(ctx, cli, basePath, etcdversion.GetVersion(), func(coll *models.Collection) bool {
if collectionName != "" && coll.Schema.Name != collectionName {
return false
}
total++
return true
})
Expand All @@ -59,6 +67,7 @@ func CollectionCommand(cli clientv3.KV, basePath string) *cobra.Command {
}

cmd.Flags().Int64("id", 0, "collection id to display")
cmd.Flags().String("name", "", "collection name to display")
return cmd
}

Expand Down

0 comments on commit f39c6ae

Please sign in to comment.