How to query 3 comments per article?

I’ll tell you how, with icings/partitionable!

If you ever wanted to limit your hasMany or belongsToMany associations, just to realize that when you set a limit() in the association’s query builder, the overall number of associated records is being limited instead, leaving you sad and disappointed, on the edge of losing your faith in humanity, then you might want to check out that small library, it transparently integrates into the ORM layer, and uses the well known association setup syntax.

It’s not stable yet, everything is subject to change, especially the various filter strategies. Any feedback is welcome, being it here, or on GitHub.


I have a deja vu from 90’s when retrieving data in a single query was preferred over making few tiny queries, which then seamed to be reasonable approach.

Idea sounds good, but solution seams to be hacky, way to hacky for me.

Best way and only correct way to do it is to retrieve data using multiple ORM queries, which can be put into methods in models, properly commented, covered by tests and and be highly re-usable.

Luckily it’s not the 90’s anymore, and we have window functions now, so that we don’t necessarily need to issue O(n) queries anymore to solve these problems :wink: