Skip to content
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

Add MongoDB Collation, Aggregation, and update/insertMany operations #1196

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bchamberlain-forbes
Copy link

I built out these modifications because we needed to use MongoDB Aggregations for dealing with complex data and utilize Collations for more efficient searching. Our models extend the Mapper class and use Aggregation as a standalone helper.

Aggregations can be built via distinct steps such as:

use DB\Mongo\Aggregation;

$agg = new Aggregation;
$agg->match(["name" => "test])
->lookup('otherCollection', 'other', 'collectionId', 'others')
->unwind('$others');

$model = new StartingDataModel();
$results = $model->aggregate($agg);

The formatting changes can likely be ignored, the existing formatting drives me crazy and is borderline unreadable ;)

@pauljherring
Copy link

The formatting changes can likely be ignored

IMHO...

Except they're drowning out the actual changes (I presume the majority of the 254/605 lines removed are such formatting - nearly half the changes .)

If you really want to overhaul the formatting, I'd suggest putting it in a separate PR, rather than doubling up on what the major thrust of this one is supposed to be.

But it's purely up to @ikkez of course...

@ikkez
Copy link
Collaborator

ikkez commented Aug 13, 2020

That's neat. Probably a useful feature to add support for the aggregation framework.
Regarding the mapper adjustments, I'm just wondering if a magic __call that links to this->collection would be more appropriate than adding multiple simple methods that just copy the behaviour like findOneAndUpdate, updateMany and insertMany etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants