跳到主要内容
版本:v2.5.x

HasCollection()

This method checks whether the specified collection exists.

Go
func (c *Client) HasCollection(ctx context.Context, option HasCollectionOption, callOptions ...grpc.CallOption) (has bool, err error)

Request Parameters​

Parameter

Description

Type

ctx

Context for the current call to work.

context.Context

option

Optional parameters of the methods.

HasCollectionOption

callOpts

Optional parameters for calling the methods.

grpc.CallOption

HasCollectionOption​

This is an interface type. The hasCollectionOption struct type implements this interface type.

You can use the NewHasCollectionOption() function to get the concrete implementation.

NewHasCollectionOption​

The signature of this method is as follows:

Go
func NewHasCollectionOption(name string) HasCollectionOption

Parameter

Description

Type

name

Name of the collection to check.

string

Return​

bool

Example​

Go
import (
"context"
"github.com/milvus-io/milvus/client/v2/milvusclient"
)

has, err = cli.HasCollection(ctx, milvusclient.NewHasCollectionOption("customized_setup_2"))
if err != nil {
// handle err
}

fmt.println(has)