Mixing raw aggregation with eloquent query #3200
-
I want to using the raw aggregation with the eloquent supporting method like where(). In my query it perform multiple filter query logic the simple logic I handle with where() but I ran to problem need to use aggregate to implement logic like $findAllRegex, $replaceAll, ... But I have so many where() clause so I dont want to refactor all of this to aggregate then I want to mix it together. Any solution for this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Raw aggregation and the new aggregation builder are not compatible with Also, if you're using version 4.3.0 or newer, you'll want to check out the Aggregation Builder, as it's a lot nicer to use than raw aggregations. |
Beta Was this translation helpful? Give feedback.
Raw aggregation and the new aggregation builder are not compatible with
where()
. As aggregation logic is purely specific to MongoDB and not supported by other databases supported by Eloquent, there is no reason for us to supportwhere()
. It could come in the future, but I can't guarantee it.Also, if you're using version 4.3.0 or newer, you'll want to check out the Aggregation Builder, as it's a lot nicer to use than raw aggregations.