From 69691cdc065dd9b12f7106e962b2f7e629608b53 Mon Sep 17 00:00:00 2001 From: Ian Macartney Date: Wed, 29 Oct 2025 17:58:24 -0700 Subject: [PATCH] allow bounds of {eq: key} --- src/client/index.ts | 2 +- src/client/positions.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index 4631edc..ffac58c 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -37,7 +37,7 @@ export type Item = { sumValue: number; }; -export type { Key, Bound }; +export type { Key, Bound, Bounds }; /** * Write data to be aggregated, and read aggregated data. diff --git a/src/client/positions.ts b/src/client/positions.ts index 20cb69a..cfee51a 100644 --- a/src/client/positions.ts +++ b/src/client/positions.ts @@ -28,8 +28,11 @@ export type TuplePrefix< export type Bounds = | SideBounds + | (K extends unknown[] + ? { prefix: TuplePrefix> } + : never) | { - prefix: TuplePrefix>; + eq: K; }; // IDs are strings so in the Convex ordering, null < IDs < arrays. @@ -83,6 +86,12 @@ export function boundsToPositions( if (bounds === undefined) { return {}; } + if ("eq" in bounds) { + return { + k1: boundToPosition("lower", { key: bounds.eq, inclusive: true }), + k2: boundToPosition("upper", { key: bounds.eq, inclusive: true }), + }; + } if ("prefix" in bounds) { const prefix: Key[] = bounds.prefix; const exploded: Key = [];