-
Notifications
You must be signed in to change notification settings - Fork 0
PHPORM-64 Remove Query\Builder::whereAll($field, $values)
#16
Conversation
9498ce8
to
32cf6ae
Compare
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.
LGTM with a suggestion to improve docs.
README.md
Outdated
@@ -631,6 +631,17 @@ $bars = Bar::raw(function ($collection) { | |||
}); | |||
``` | |||
|
|||
**Other operators** | |||
|
|||
You can use any [MongoDB query operator](https://www.mongodb.com/docs/manual/reference/operator/query/#query-selectors) with the `where` function: |
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.
Consider adding the resulting query from this call for the sake of completeness.
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.
Only for this example? If I add the generated BSON query to all the examples, the README will become very very long. Or I can use a collapsible section.
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 think it can just be added for this example. It's unique in that it's showing you how to use an arbitrary query operator, so the goal should be communicating what you said in this comment:
Basically,
where($field, $operator, $values)
generates{ $field: { $operator: $values } }
That said, I think the $all
with $elemMatch
example would be better suited for a test case. That was my intention in this comment.
For a documentation example, I think the current test case works better:
$builder->where('tags', 'all', ['ssl', 'security'])
My reasoning:
- The test case lets us know that the more complex query is possible using this API
- The documentation would do well to toe the line between explaining to users how to run an arbitrary query with
where()
while also not overwhelming or distracting them with a very niche query
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 added the test and revisited the doc. There is already an example with $all
.
All operator listed in Builder::$operators
are supported.
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.
LGTM with the current test case moved to a docs example (and resulting query shown), and the $all
with $elemMatch
example moved to the test.
README.md
Outdated
@@ -631,6 +631,17 @@ $bars = Bar::raw(function ($collection) { | |||
}); | |||
``` | |||
|
|||
**Other operators** | |||
|
|||
You can use any [MongoDB query operator](https://www.mongodb.com/docs/manual/reference/operator/query/#query-selectors) with the `where` function: |
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 think it can just be added for this example. It's unique in that it's showing you how to use an arbitrary query operator, so the goal should be communicating what you said in this comment:
Basically,
where($field, $operator, $values)
generates{ $field: { $operator: $values } }
That said, I think the $all
with $elemMatch
example would be better suited for a test case. That was my intention in this comment.
For a documentation example, I think the current test case works better:
$builder->where('tags', 'all', ['ssl', 'security'])
My reasoning:
- The test case lets us know that the more complex query is possible using this API
- The documentation would do well to toe the line between explaining to users how to run an arbitrary query with
where()
while also not overwhelming or distracting them with a very niche query
b6194e6
to
2d89bbf
Compare
Fix PHPORM-64
Use
where($field, 'all', $values)
instead.Introduced in 2017 without explaining the motivation mongodb/laravel-mongodb#1320