From 401b88abb615b630c25d7a878d0f1ff22915c064 Mon Sep 17 00:00:00 2001 From: ogzhanolguncu Date: Fri, 5 Jul 2024 16:15:25 +0300 Subject: [PATCH] feat: add includeData support to range --- src/commands/client/fetch/index.test.ts | 1 + src/commands/client/range/index.test.ts | 6 +++--- src/commands/client/range/index.ts | 1 + src/commands/client/upsert/index.test.ts | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/commands/client/fetch/index.test.ts b/src/commands/client/fetch/index.test.ts index a54de0c..ff3ab6f 100644 --- a/src/commands/client/fetch/index.test.ts +++ b/src/commands/client/fetch/index.test.ts @@ -64,6 +64,7 @@ describe("FETCH", () => { }); describe("FETCH with Index Client", () => { + afterAll(async () => await resetIndexes()); const index = new Index({ token: process.env.UPSTASH_VECTOR_REST_TOKEN!, url: process.env.UPSTASH_VECTOR_REST_URL!, diff --git a/src/commands/client/range/index.test.ts b/src/commands/client/range/index.test.ts index 8786e3d..7e973d0 100644 --- a/src/commands/client/range/index.test.ts +++ b/src/commands/client/range/index.test.ts @@ -17,7 +17,7 @@ describe("RANGE", () => { test("should paginate records successfully", async () => { const randomizedData = new Array(20) .fill("") - .map(() => ({ id: randomID(), vector: range(0, 384) })); + .map(() => ({ id: randomID(), data: "Test data" })); const payloads = randomizedData.map((data) => new UpsertCommand(data).exec(client)); await Promise.all(payloads); @@ -27,9 +27,9 @@ describe("RANGE", () => { const res = await new RangeCommand({ cursor: 0, limit: 5, - includeVectors: true, + includeData: true, }).exec(client); - expect(res.nextCursor).toBe("5"); + expect(res.vectors[0].data).toEqual("Test data"); }); }); diff --git a/src/commands/client/range/index.ts b/src/commands/client/range/index.ts index eec1233..b5a5171 100644 --- a/src/commands/client/range/index.ts +++ b/src/commands/client/range/index.ts @@ -7,6 +7,7 @@ type RangeCommandPayload = { limit: number; includeVectors?: boolean; includeMetadata?: boolean; + includeData?: boolean; }; type RangeCommandOptions = { namespace?: string }; diff --git a/src/commands/client/upsert/index.test.ts b/src/commands/client/upsert/index.test.ts index e2a1354..0d3c423 100644 --- a/src/commands/client/upsert/index.test.ts +++ b/src/commands/client/upsert/index.test.ts @@ -172,6 +172,7 @@ describe("UPSERT with Index Client", () => { }); describe("Upsert with new data field", () => { + afterAll(async () => await resetIndexes()); test("should add data to data field - /upsert-data", async () => { const id = randomID(); const data = "testing data";