-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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.
All reactions
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 support where()
. 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.
Replies: 1 comment 4 replies
-
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 support where()
. 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.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank for your reply, I will check out the Aggregation builder. To be correct it still need to refactor to archive this right.
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, you won't be able to use where()
in the aggregation builder, but it will be easier for us to support passing a query builder instance to Stage::match()
in the future than it would be to handle it in raw()
.
Beta Was this translation helpful? Give feedback.
All reactions
-
ok, thank a lot for your reply
Beta Was this translation helpful? Give feedback.
All reactions
-
You're too quick for me to edit my own reply. I created PHPORM-262 to track this improvement. Please follow that ticket for updates on this topic.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1