mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-27 07:09:57 +00:00
This removes the type definitions for a number of important TypeScript interfaces from `.npmignore` so that the package is not incorrectly typed `any` in a number of places. --- Presently the `opts` argument to `lancedb.connect` is typed `any`, even though it shouldn't be. <img width="560" alt="image" src="https://github.com/user-attachments/assets/5c974ce8-5a59-44a1-935d-cbb808f0ea24"> Clicking into the type definitions for the published package, it has the correct type signature: <img width="831" alt="image" src="https://github.com/user-attachments/assets/6e39a519-13ff-4ca8-95ae-85538ac59d5d"> However, `ConnectionOptions` is imported from `native.js` (along with a number of other imports a bit further down): <img width="384" alt="image" src="https://github.com/user-attachments/assets/10c1b055-ae78-4088-922e-2816af64c23c"> This is not otherwise an issue, except that the type definitions for `native.js` are not included in the published package: <img width="217" alt="image" src="https://github.com/user-attachments/assets/f15cd3b6-a8de-4011-9fa2-391858da20ec"> I haven't compiled the Rust code and run the build script, but I strongly suspect that disincluding the type definitions in `.npmignore` is ultimately the root cause here.
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)
- MacOS (Intel and ARM/M1/M2)
- Windows (x86_64 only)
We do not yet support musl-based Linux (such as Alpine Linux) or aarch64 Windows.
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 a more complete example.
Development
npm run build
npm run test
Running lint / format
LanceDb uses biome for linting and formatting. if you are using VSCode you will need to install the official Biome extension. To manually lint your code you can run:
npm run lint
to automatically fix all fixable issues:
npm run lint-fix
If you do not have your workspace root set to the nodejs directory, unfortunately the extension will not work. You can still run the linting and formatting commands manually.
Generating docs
npm run docs
cd ../docs
# Asssume the virtual environment was created
# python3 -m venv venv
# pip install -r requirements.txt
. ./venv/bin/activate
mkdocs build