Elffuss BraidHub

kikocis/lancedb public

85830ec79fd2 · 1.7 KiBRenderedRawPermalink
1**@lancedb/lancedb** • [**Docs**](globals.md)
2
3***
4
5# LanceDB JavaScript SDK
6
7A JavaScript library for [LanceDB](https://github.com/lancedb/lancedb).
8
9## Installation
10
11```bash
12npm install @lancedb/lancedb
13```
14
15This will download the appropriate native library for your platform. We currently
16support:
17
18- Linux (x86_64 and aarch64)
19- MacOS (Intel and ARM/M1/M2)
20- Windows (x86_64 only)
21
22We do not yet support musl-based Linux (such as Alpine Linux) or aarch64 Windows.
23
24## Usage
25
26### Basic Example
27
28```javascript
29import * as lancedb from "@lancedb/lancedb";
30const db = await lancedb.connect("data/sample-lancedb");
31const table = await db.createTable("my_table", [
32 { id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
33 { id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 },
34]);
35const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
36console.log(results);
37```
38
39The [quickstart](../basic.md) contains a more complete example.
40
41## Development
42
43```sh
44npm run build
45npm run test
46```
47
48### Running lint / format
49
50LanceDb uses [biome](https://biomejs.dev/) for linting and formatting. if you are using VSCode you will need to install the official [Biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) extension.
51To manually lint your code you can run:
52
53```sh
54npm run lint
55```
56
57to automatically fix all fixable issues:
58
59```sh
60npm run lint-fix
61```
62
63If 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.
64
65### Generating docs
66
67```sh
68npm run docs
69
70cd ../docs
71# Asssume the virtual environment was created
72# python3 -m venv venv
73# pip install -r requirements.txt
74. ./venv/bin/activate
75mkdocs build
76```