mirror of
https://github.com/lancedb/lancedb.git
synced 2026-05-24 15:30:38 +00:00
2.3 KiB
2.3 KiB
Table of contents
Installation
npm install vectordb
This will download the appropriate native library for your platform. We currently support x86_64 Linux, aarch64 Linux, Intel MacOS, and ARM (M1/M2) MacOS. We do not yet support Windows or musl-based Linux (such as Alpine Linux).
Classes
Methods
- add
- countRows
- createIndex
- createTable
- delete
- dropTable
- listIndices
- indexStats
- openTable
- overwrite
- schema
- search
- tableNames
- update
Example code
// connect to a remote DB
const lancedb = require('vectordb');
const db = await lancedb.connect({
uri: "db://your-project-name",
apiKey: "sk_...",
region: "us-east-1"
});
// create a new table
const tableName = "my_table"
const table = await db.createTable(tableName,
[
{ id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
{ id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 }
]
)
[{ id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
{ id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 }])
// list the table
const tableNames_1 = await db.tableNames('')
// add some data and search should be okay
const data = [
{ id: 3, vector: [10.3, 1.9], item: "test1", price: 30.0 },
{ id: 4, vector: [6.2, 9.2], item: "test2", price: 40.0 }
]
// create the index for the table
await table.createIndex({
metric_type: 'L2',
column: 'vector'
})
let result = await table.search([2.8, 4.3]]).select(["vector", "price"]).limit(1).execute()
// update the data
await table.update({
where: "id == 1",
values: { item: "foo1" }
})
//drop the table
await db.dropTable(tableName)