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