Files
lancedb/nodejs
Tomwang.eth 855bec2a57 fix(node): make tags.list() values plain serializable objects (#4915)
Related: #4849 (same defect class on `branches.list()`, fixed in #4914).

**Problem**
`Tags.list()` returns napi class instances whose fields live on the
prototype, so `console.log`, spread and `JSON.stringify` show `{}` — the
documented example (`{ "v1": { version: 1, manifestSize: ... } }`)
doesn't match what users actually see. Property access
(`tags["v1"].version`) works, which is why the existing tests didn't
catch it.

**Change**
- `TagContents` stays a runtime napi class export: existing ESM named
imports of `TagContents` and `instanceof` checks keep working, and
existing TypeScript values remain assignable to it.
- `nodejs/lancedb/table.ts` post-processes `Tags.prototype.list()`
results, promoting `version` and `manifestSize` to own enumerable
properties on each returned instance by reusing the class getters and
setters. Values are now enumerable, spreadable and JSON-serializable
with no fields added, removed or renamed.
- TS-only: the Python SDK already returns proper dicts with both fields.

**Tests**
- New regression test in `nodejs/__test__/table.test.ts` covers the
named import and `instanceof` alongside own-enumerable keys, spread and
a JSON round-trip through `tags.list()`.
- The tag tests from #5145 are kept and pass against this change.
- Verified locally on Linux x86_64: `tsc -b`, Biome checks, and the
focused tags suite (4 passed), including `tags.create(name)` /
`tags.create(name, null)` behavior.
2026-11-30 19:14:23 +08:00
..
2025-01-29 08:27:07 -08:00

LanceDB JavaScript SDK

A JavaScript library for LanceDB.

Installation

npm install @lancedb/lancedb

This will download the appropriate native library for your platform. We currently support:

  • Linux (x86_64 and aarch64 on glibc and musl)
  • macOS (Apple silicon / arm64)
  • Windows (x86_64 and aarch64)

Usage

Basic Example

import * as lancedb from "@lancedb/lancedb";
const db = await lancedb.connect("data/sample-lancedb");
const table = await db.createTable("my_table", [
  { id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
  { id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 },
]);
const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
console.log(results);

The quickstart contains more complete examples.

Development

See CONTRIBUTING.md for information on how to contribute to LanceDB.