Added Comprehensive CouchDB Partitioned Database Support #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CHANGELOG
Added Comprehensive CouchDB Partitioned Database Support
This pull request adds full support for CouchDB 3.0+ partitioned databases and enhances the changes feed with design document filter query parameters.
🎯 Overview
Total Changes: 12 files changed, 734 insertions(+), 9 deletions(-)
Commits: 6 commits (excluding initial plan)
Tests Added: 9 comprehensive unit tests
🚀 New Features
1. Partitioned Database Query Operations
Added 4 new public methods to
ICouchDatabase<TSource>:GetPartitionInfoAsync(string partitionKey, CancellationToken)GET /{db}/_partition/{key}QueryPartitionAsync(string partitionKey, string mangoQueryJson, CancellationToken)POST /{db}/_partition/{key}/_findQueryPartitionAsync(string partitionKey, object mangoQuery, CancellationToken)POST /{db}/_partition/{key}/_findGetPartitionAllDocsAsync(string partitionKey, CancellationToken)GET /{db}/_partition/{key}/_all_docsImplementation Details:
Check.NotNull()pattern2. Design Document Filter Query Parameters for Changes Feed
New capability to pass custom query parameters to design document filters:
ChangesFeedOptions.QueryParameterspropertyDictionary<string, string>?req.queryChangesFeedFilter.DesignDocument(string filterName, Dictionary<string, string>? queryParameters)Use Case: Enables efficient partition-based change tracking using design document filters, which is significantly more performant than selector filters for partitioned databases.
📦 New Types
CouchPartitionInfo(sealed class)Properties:
DbName- Database nameDocCount- Number of documents in partitionDocDelCount- Number of deleted documentsPartition- Partition keySizes- Size information (active, external)DatabaseProps(sealed class)Properties:
Partitioned- Boolean indicating if database is partitionedAllDocsResult<T>(internal class)Internal DTO for
_all_docsAPI responses with nested row structureDesignDocumentChangesFeedFilter(internal class)Internal filter type for design document filters with query parameters
🔧 Enhancements
Enhanced
CouchDatabaseInfoPropsproperty of typeDatabasePropsEnhanced Changes Feed Implementation
ApplyChangesFeedOptions()helper method to reduce code duplicationApplyDesignDocumentFilterParams()helper method for reusable filter logicGetChangesAsync()andGetContinuousChangesAsync()now support custom query parameters🧪 Testing
New Test Files
Partition_Tests.cs(6 tests):GetPartitionInfo- Tests partition metadata retrievalQueryPartitionWithJson- Tests JSON string queryQueryPartitionWithObject- Tests object-based queryGetPartitionAllDocs- Tests fetching all partition documentsGetPartitionInfo_WithSpecialCharacters- Tests URL encodingGetDatabaseInfo_WithPartitionedProperty- Tests database partitioned detectionChangesFeed_DesignDocumentFilter_Tests.cs(3 tests):GetChangesAsync_WithDesignDocumentFilter_AppliesFilterName- Tests basic filter applicationGetChangesAsync_WithDesignDocumentFilterAndQueryParams_AppliesParameters- Tests filter with parametersGetChangesAsync_WithOptionsQueryParameters_AppliesParameters- Tests parameters via optionsAll tests use Flurl's
HttpTestfor mocking, consistent with existing test patterns.📚 Documentation
README Updates
New Section: "Partitioned Databases"
partition:id)Enhanced Section: "Feed Filter"
DesignDocumentfilter documentation🏗️ Code Quality
Architectural Consistency
CancellationTokensupport throughoutConfigureAwait(false)on all async callsinternalvisibilityInput Validation
Check.NotNull()helperDesignDocumentChangesFeedFilterCode Organization
Security
🔄 API Compatibility
Breaking Changes: None - All changes are additive
New Public APIs:
ICouchDatabase<TSource>.GetPartitionInfoAsync()ICouchDatabase<TSource>.QueryPartitionAsync()(2 overloads)ICouchDatabase<TSource>.GetPartitionAllDocsAsync()ChangesFeedOptions.QueryParameterspropertyChangesFeedFilter.DesignDocument()static factory methodEnhanced Types:
CouchDatabaseInfo.Propsproperty added📋 Usage Examples
Partitioned Database Operations
Design Document Filter with Query Parameters
🎯 Compatibility
📊 Metrics
✅ Quality Checklist