New mango operator proposal : match keys of a map#3041
New mango operator proposal : match keys of a map#3041janl merged 1 commit intoapache:masterfrom borkowmichal:feature/add-mango-operator-match-key-in-map
Conversation
|
Approved, but I’d like to have one more +1 just to make sure :) |
davisp
left a comment
There was a problem hiding this comment.
This looks to be implemented correctly but I've got two questions. Is there a motivating use case we should document? The example in the test is equivalent to the $exists operator and I'm not personally seeing an obvious other use for this, though I'd wager that's just my lack of imagination this early in the morning.
Secondly, the logic currently has a bit of an implicit $or going on since any key that matches would cause this to match. So testing for the lack of a key or some sort of negative condition wouldn't work. I wonder if we couldn't make it slightly more generalized if we matched the sub-selector against an array of keys?
|
The ergonomics of an |
|
For the use case, the example is not representative in itself indeed. Given this partial representation of a document that has delegations (represented by the map keys), we would like to get all documents with a specific delegation. We also make more complex queries, and we use JSON indexes. In this situation the That's what motivated us to create this operator. |
|
@janl @borkowmichal Ah! Gotchya, that makes perfect sense. |
Overview
Proposition of a new Mango query operator that allows to query on the keys of a map.
It is related to the already existing
$elemMatchbut instead on the elements of an array it is applied on the keysof a map.
For the name of the operator I don't know what's best suited, I used
$keyMapMatch.Related Issues or Pull Requests
apache/couchdb-documentation#574
Checklist
rel/overlay/etc/default.ini