diff --git a/CHANGELOG.md b/CHANGELOG.md index 74472d6..9a07b5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 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) - fixed: Correctly ignore archived rolling databases. diff --git a/src/couchdb/rolling-database.ts b/src/couchdb/rolling-database.ts index 9a44131..751c59b 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 } ) } @@ -436,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( @@ -548,7 +551,7 @@ export function makeRollingDatabase( } const { exists } = clusterHasDatabase( replicatorSetup?.doc, - pool.defaultName, + watchCluster, setup ) if (exists) {