-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: END-335 support for all and some #3
Changes from 3 commits
5344e44
279b3e6
0a9b055
2bb6ab8
a067577
8dc6875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/node_modules/ | ||
coverage |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,20 @@ function whereFilter(where) { | |
if (Array.isArray(value)) { | ||
const matcher = where[key]; | ||
|
||
if (matcher.some) { | ||
return value.some(function(v) { | ||
return whereFilter(matcher.some)(v); | ||
}); | ||
} | ||
if (matcher.all) { | ||
return value.every(function(v) { | ||
return whereFilter(matcher.all)(v); | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So these can nest, right? I guess we can't ever have a property called some or all as part of job data now?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they can nest, which I think they can, it would be good to have a test for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can still use "some" and "all" as object keys. They only function in a "special" way when they are applied to an array property. Much like how use of "inq" and "eq" don't stop you from using those as property names. They only kick in as "special" when they are used on certain contexts where they only makes sense as special There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh.. that's good to know. |
||
|
||
// below is code for doing `arrayOfScalars: singleContainedValue` | ||
// or an `neq` variant of that | ||
|
||
// The following condition is for the case where we are querying with | ||
// a neq filter, and when the value is an empty array ([]). | ||
if (matcher.neq !== undefined && value.length <= 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a where filter with some for an empty array will also return false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is based on how Array.prototype.some and Array.prototype.every (we have chosen to alias as all) work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool