Implement $hasAny operator for any-of array-containment matching#335
Merged
Conversation
Copilot
AI
changed the title
[WIP] [WIP] Implement $hasAny operator in DCB query support based on feedback
Implement $hasAny operator for any-of array-containment matching
Jul 18, 2026
albe
reviewed
Jul 18, 2026
albe
reviewed
Jul 18, 2026
Owner
|
@copilot resolve the merge conflicts in this pull request |
Contributor
Author
Resolved. Two conflicts in the merge with
All 687 tests pass. |
albe
marked this pull request as ready for review
July 18, 2026 12:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Thanks for the feedback on #331. This PR implements the
$hasAnyoperator as a sibling to$has, providing explicit any-of array-containment semantics.Original PR: #331
Triggering review: #331 (comment)
Changes Made
src/utils/metadataUtil.js): Added$hasAnycase inbuildOperatorChecks— compiles toArray.isArray(v) && expectedValues.some(x => v.includes(x)).src/utils/metadataUtil.js): Added$hasAnybranch inbuildMatcherTreeChild— anchors on the"key":[opener and callsindexOfSameLevelfor each pre-serialized value pattern, short-circuiting on the first hit.src/IndexMatcher.js): AddedisLoneHasAnyArrayhelper and$hasAnyhandling infindDiscriminant— registers the matcher under each expected value as a discriminant key, enabling O(1) routing when any document array element matches (deduplication handled by the existingcalledset inforEachMatch).streams.md,api.md,dcb.md, andchangelog.mdto document$hasAnyalongside$has.test/metadataUtil.spec.jsand discriminant registration/lookup tests intest/IndexMatcher.spec.js.Usage