DropCollection
This operation drops a collection and all its data permanently.
go
func (c *Client) DropCollection(ctx context.Context, option DropCollectionOption, callOptions ...grpc.CallOption) error
Request Syntax
Creates the request for DropCollection().
go
option := milvusclient.NewDropCollectionOption(name)
err := client.DropCollection(ctx, option)
PARAMETERS:
-
name (string) -
[REQUIRED]
The name of the target collection.
BUILDER METHODS:
-
NewDropCollectionOption(name string)Creates the request for DropCollection().
RETURN TYPE:
error
RETURNS:
Returns nil on success, or an error describing what went wrong.
ERROR HANDLING:
-
error
The operation fails. Check
err != nilfor failure details.
Example
Demonstrates DropCollection() usage.
go
import (
"context"
"log"
"github.com/milvus-io/milvus/client/v3/milvusclient"
)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
milvusAddr := "YOUR_CLUSTER_ENDPOINT"
cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
})
if err != nil {
log.Fatal("failed to connect to milvus server: ", err.Error())
}
defer cli.Close(ctx)
err = cli.DropCollection(ctx, milvusclient.NewDropCollectionOption("customized_setup_2"))
if err != nil {
// handle err
}