List index names (Go)
|
Tables with the Data API are currently in public preview. Development is ongoing, and the features and functionality are subject to change. Hyper-Converged Database (HCD), and the use of such, is subject to the DataStax Preview Terms. |
Gets the names of the indexes for a table.
|
Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart. |
Result
Returns the index names for a table as an unordered slice of strings.
Parameters
Use the ListIndexNames method, which belongs to the Table type.
Method signature
func (t *Table) ListIndexNames(
ctx context.Context,
opts ...options.ListIndexesOption
) ([]string, error)
| Name | Type | Summary |
|---|---|---|
|
|
The context for the operation. |
|
Optional.
A builder to generate options for this operation.
See Methods of the |
| Method | Summary |
|---|---|
|
Optional. General API options for this operation, including the timeout. |
Examples
The following examples demonstrate how to get the names of the indexes for a table.
List index names
package main
import (
"context"
"fmt"
"log"
"github.com/datastax/astra-db-go/v2/astra"
"github.com/datastax/astra-db-go/v2/astra/options"
)
func main() {
ctx := context.Background()
// Get an existing table
client := astra.NewClient(
options.API().SetEnvironment(options.EnvironmentHCD),
)
database := client.Database(
"API_ENDPOINT",
options.API().
SetUsernamePasswordTokenProvider(
"USERNAME",
"PASSWORD",
).
SetKeyspace("KEYSPACE_NAME"),
)
table := database.Table("TABLE_NAME")
// List index names
names, err := table.ListIndexNames(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(names)
}
Client reference
For more information, see the client reference.