laravel-mongodb
laravel-mongodb copied to clipboard
Group + order doesn't work
Hi,
I try to get the oldest item in each group from a collection :
MyModel->orderBy('date', 'asc')->groupBy('color')->get(['color', 'date']);
It doesn't work : each group gets the last date of the collection, like if the orderBy wasn't taken into account.
Any idea on how to perform that ?
what is ->group() ? is that a custom scope? Or a new feature? or do you mean groupBy?
Yes I mean groupBy, thank you I edited.
MyModel->groupBy('color')->orderBy('date', 'asc')->get(['color', 'date']);
maybe this works
@jenssegers is that possible... to use both ?
@muzafarali Did you solve a problem?