BLOB type (TypeScript)
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 |
You can insert binary data as a DataAPIBlob object.
The DataAPIBlob class and its blob shorthand accept DataAPIBlobLike input, such as ArrayBuffer and { $binary: string }.
The TypeScript client returns binary data received from the Data API as a DataAPIBlob object.
The DataAPIBlob class provides methods like asArrayBuffer() for accessing the binary data.
import {
DataAPIClient,
UsernamePasswordTokenProvider,
DataAPIBlob,
} from "@datastax/astra-db-ts";
// Get an existing table
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
keyspace: "KEYSPACE_NAME",
});
const table = database.table("TABLE_NAME");
// Insert binary values
(async function () {
const result = await table.insertOne({
example_blob: new DataAPIBlob({ $binary: "PfvnbT7peNU/Sfvn" }),
another_example_blob: new DataAPIBlob(Buffer.from([0x0, 0x1, 0x2])),
title: "Example",
});
})();