BLOB type (Go)

Use the blob type for binary data.

Although you can store binary-encoded vector data in a blob column, you cannot create a vector index or perform a vector search on the column. Instead, use the vector type to store vector data.

Due to a known issue with filtering on blob, DataStax does not recommend using blob in primary keys.

You can insert binary data as a []byte slice or a Base64-encoded string with $binary. []byte slices are automatically Base64-encoded.

By default, the Go client returns binary data received from the Data API as a []byte slice.

package main

import (
	"context"
	"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()

	database := client.Database(
		"API_ENDPOINT",
		options.API().SetToken("APPLICATION_TOKEN"),
	)

	table := database.Table("TABLE_NAME")

	// Insert binary values
	_, err := table.InsertOne(
		ctx,
		map[string]any{
			// Using $binary with a Base64-encoded string
			"example_blob": map[string]any{
				"$binary": "PfvnbT7peNU/Sfvn",
			},
			// No need for explicit '$binary' with a byte array
			"another_example_blob": []byte{
				0x3d,
				0xfb,
				0xe7,
				0x6d,
				0x3e,
				0xe9,
				0x78,
				0xd5,
				0x3f,
				0x49,
				0xfb,
				0xe7,
			},
			"title": "Example",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
}

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM