My 'limit' => 3 gets ignored because paginate is set to true by default, and therefore the query will ignore this and get all entries.
Currently I'm working on a huge export of entries to import via Feed Me somewhere else, and I want to run some tests but not with all 900+ entries I have in that channel. I just want to test with 3. I finally figured out that my endpoint was still querying for every entry because it was set to paginate the entries, and I guess the logic assumes you wouldn't want to paginate and limit at the same time. If paginate is true, then I think it would be better to paginate only if the elements returned exceed whatever elementsPerPage is set to.
So for example, if this is what's happening:
'paginate' => true,
'elementsPerPage' => 10,
And you're querying with a limit of 12, you would have two pages. If you're querying with a limit of 9, then you would just have one page.
There's no mention of this in the docs, so it feels like an unfortunate gotcha that requires you to remember to set 'paginate' => false anytime you want to limit your query.
Let's say I have hundreds of entries in an
articles
channel. Consider this endpoint:My
'limit' => 3
gets ignored becausepaginate
is set totrue
by default, and therefore the query will ignore this and get all entries.Currently I'm working on a huge export of entries to import via Feed Me somewhere else, and I want to run some tests but not with all 900+ entries I have in that channel. I just want to test with 3. I finally figured out that my endpoint was still querying for every entry because it was set to paginate the entries, and I guess the logic assumes you wouldn't want to paginate and limit at the same time. If
paginate
istrue
, then I think it would be better to paginate only if the elements returned exceed whateverelementsPerPage
is set to.So for example, if this is what's happening:
And you're querying with a
limit
of12
, you would have two pages. If you're querying with alimit
of9
, then you would just have one page.There's no mention of this in the docs, so it feels like an unfortunate gotcha that requires you to remember to set
'paginate' => false
anytime you want tolimit
your query.