From a797f5fe59f77f2bf6c8757b36a6ab9e967e043b Mon Sep 17 00:00:00 2001 From: Cory Grinstead Date: Fri, 21 Jun 2024 16:03:58 -0500 Subject: [PATCH] feat(nodejs): feature parity [5/N] - add `query.filter()` alias (#1391) to make the transition from `vectordb` to `@lancedb/lancedb` as seamless as possible, this adds `query.filter` with a deprecated tag. depends on https://github.com/lancedb/lancedb/pull/1390 see actual diff here https://github.com/universalmind303/lancedb/compare/list-indices-name...universalmind303:query-filter --- nodejs/__test__/table.test.ts | 4 ++++ nodejs/lancedb/query.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/nodejs/__test__/table.test.ts b/nodejs/__test__/table.test.ts index 91095764..a205647f 100644 --- a/nodejs/__test__/table.test.ts +++ b/nodejs/__test__/table.test.ts @@ -362,6 +362,10 @@ describe("When creating an index", () => { for await (const r of tbl.query().where("id > 1").select(["id"])) { expect(r.numRows).toBe(298); } + // should also work with 'filter' alias + for await (const r of tbl.query().filter("id > 1").select(["id"])) { + expect(r.numRows).toBe(298); + } }); // TODO: Move this test to the query API test (making sure we can reject queries diff --git a/nodejs/lancedb/query.ts b/nodejs/lancedb/query.ts index 13604e7c..ec00d6e4 100644 --- a/nodejs/lancedb/query.ts +++ b/nodejs/lancedb/query.ts @@ -114,6 +114,14 @@ export class QueryBase< this.inner.onlyIf(predicate); return this as unknown as QueryType; } + /** + * A filter statement to be applied to this query. + * @alias where + * @deprecated Use `where` instead + */ + filter(predicate: string): QueryType { + return this.where(predicate); + } /** * Return only the specified columns.