List user-defined types (UDTs) (Go)
Gets information about the user-defined types (UDTs) in a keyspace.
|
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 an unordered slice of UDTDescriptor structs that describe each user-defined type in the keyspace.
Parameters
Use the ListTypes method, which belongs to the Db type.
Method signature
func (d *Db) ListTypes(
ctx context.Context,
opts ...options.ListTypesOption
) ([]results.UDTDescriptor, 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. The keyspace to inspect. Default: The working keyspace for the database.
This is |
|
Optional. General API options for this operation, including the timeout. |
Examples
The following examples demonstrate how to get metadata about user-defined types in a keyspace.
package main
import (
"context"
"encoding/json"
"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 a database
client := astra.NewClient()
database := client.Database(
"API_ENDPOINT",
options.API().SetToken("APPLICATION_TOKEN"),
)
// List type metadata
types, err := database.ListTypes(ctx)
if err != nil {
log.Fatal(err)
}
output, err := json.Marshal(types)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(output))
}
Client reference
For more information, see the client reference.