Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mixing raw aggregation with eloquent query #3200

Answered by alcaeus
TranLong183 asked this question in Q&A
Discussion options

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

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
4 replies
Comment options

Thank for your reply, I will check out the Aggregation builder. To be correct it still need to refactor to archive this right.

Comment options

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().

Comment options

ok, thank a lot for your reply

Comment options

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.

Answer selected by TranLong183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /