From b917e5623fb185615349587c11ced331858c3178 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Fri, 22 Aug 2025 16:00:14 -0700 Subject: [PATCH 1/2] Accept a chunk size for rolling streaming queries --- CHANGELOG.md | 2 ++ src/couchdb/rolling-database.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74472d6..49c47c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- added: Accept a chunk size for rolling database streaming queries. + ## 0.2.22 (2025-07-03) - fixed: Correctly ignore archived rolling databases. diff --git a/src/couchdb/rolling-database.ts b/src/couchdb/rolling-database.ts index 9a44131..7f3ce21 100644 --- a/src/couchdb/rolling-database.ts +++ b/src/couchdb/rolling-database.ts @@ -408,11 +408,12 @@ export function makeRollingDatabase( connection: ServerScope, design: string, view: string, - opts: RollingViewParams + opts: RollingViewParams & { chunkSize?: number } ): AsyncIterableIterator> { const { afterDate, partition, + chunkSize, // Native CouchDB options: ...rest } = opts @@ -426,7 +427,7 @@ export function makeRollingDatabase( : db.partitionedView(partition, design, view, allParams)) return rows }, - { afterDate } + { chunkSize, afterDate } ) } From 7b53edcba1ae0922081a762a0172c3ae30c65e91 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Fri, 22 Aug 2025 16:01:36 -0700 Subject: [PATCH 2/2] Fix a rolling-database setup bug If the `watchCluster` differed from the default cluster, we could end with the wrong set of databases. --- CHANGELOG.md | 1 + src/couchdb/rolling-database.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49c47c0..9a07b5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - added: Accept a chunk size for rolling database streaming queries. +- fixed: Use the `watchCluster` to filter rolling databases, not the default pool cluster. ## 0.2.22 (2025-07-03) diff --git a/src/couchdb/rolling-database.ts b/src/couchdb/rolling-database.ts index 7f3ce21..751c59b 100644 --- a/src/couchdb/rolling-database.ts +++ b/src/couchdb/rolling-database.ts @@ -437,7 +437,9 @@ export function makeRollingDatabase( if (database.startDate.valueOf() > date.valueOf()) continue return database.name } - throw new Error(`No rolling database exists for ${date.toISOString()}`) + throw new Error( + `No rolling database exists for ${name} at ${date.toISOString()}` + ) } async function insert( @@ -549,7 +551,7 @@ export function makeRollingDatabase( } const { exists } = clusterHasDatabase( replicatorSetup?.doc, - pool.defaultName, + watchCluster, setup ) if (exists) {