mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-15 16:22:27 +00:00
1.4 KiB
1.4 KiB
@lancedb/lancedb • Docs
@lancedb/lancedb / blob
Function: blob()
function blob(name, options): Field
Declares a lance.blob.v2 column.
Query results are descriptors, not payload bytes. Use Table.fetchBlobs or Table.fetchBlobFiles to read bytes. Blobs inside lists can be written and queried as descriptors, but cannot currently be fetched because a row ID does not identify a list element.
Parameters
-
name:
string -
options:
BlobOptions={}
Returns
Field
Example
import { readFile } from "node:fs/promises";
import { Field, Int64, Schema } from "apache-arrow";
import { blob, connect } from "@lancedb/lancedb";
const db = await connect("./data");
const video = await readFile("clip.mp4");
const table = await db.createTable(
"videos",
[{ id: 1n, video }],
{
schema: new Schema([
new Field("id", new Int64()),
blob("video"),
]),
},
);
const rows = await table.query().select(["id"]).withRowId().toArray();
const rowIds = rows.map((row) => row._rowid as bigint);
const bytes = await table.fetchBlobs("video", rowIds);
const [handle] = await table.fetchBlobFiles("video", rowIds);
const size = handle!.size();
const header = await handle!.readRange(0n, size < 65536n ? size : 65536n);