mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-13 07:12:57 +00:00
chore: update JS/TS example in README (#898)
- The JS/TS library actually expects named parameters via an object in `.createTable()` rather than individual arguments - Added example on how to search rows by criteria without a vector search. TS type of `.search()` currently has the `query` parameter as non-optional so we have to pass undefined for now.
This commit is contained in:
committed by
Weston Pace
parent
a617ad35ff
commit
5a12224a02
13
README.md
13
README.md
@@ -51,12 +51,19 @@ npm install vectordb
|
||||
const lancedb = require('vectordb');
|
||||
const db = await lancedb.connect('data/sample-lancedb');
|
||||
|
||||
const table = await db.createTable('vectors',
|
||||
[{ id: 1, vector: [0.1, 0.2], item: "foo", price: 10 },
|
||||
{ id: 2, vector: [1.1, 1.2], item: "bar", price: 50 }])
|
||||
const table = await db.createTable({
|
||||
name: 'vectors',
|
||||
data: [
|
||||
{ id: 1, vector: [0.1, 0.2], item: "foo", price: 10 },
|
||||
{ id: 2, vector: [1.1, 1.2], item: "bar", price: 50 }
|
||||
]
|
||||
})
|
||||
|
||||
const query = table.search([0.1, 0.3]).limit(2);
|
||||
const results = await query.execute();
|
||||
|
||||
// You can also search for rows by specific criteria without involving a vector search.
|
||||
const rowsByCriteria = await table.search(undefined).where("price >= 10").execute();
|
||||
```
|
||||
|
||||
**Python**
|
||||
|
||||
Reference in New Issue
Block a user