From 5a12224a022dfa39dde98c6aaa14e61aef4dbd30 Mon Sep 17 00:00:00 2001 From: Abraham Lopez <10536776+AbrahamLopez10@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:09:45 -0500 Subject: [PATCH] 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. --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0fdfc583..d2c71186 100644 --- a/README.md +++ b/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**