How to use .limit() inside preload with pagination? #3241
Answered
by
thetutlage
CodeArtisT75
asked this question in
Help
-
Hello guys. How can I load limited relations during preload with paginating? example code: const posts = Post.preload('tags', tagBuilder => {
tagBuilder.limit(2);
}).paginate(page, perPage); in the example, I want to load 2 tags for each post but it only returns the first 2 tags in all posts. |
Beta Was this translation helpful? Give feedback.
Answered by
thetutlage
Oct 14, 2021
Replies: 1 comment 1 reply
-
Use the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
CodeArtisT75
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the
groupLimit
method. https://docs.adonisjs.com/reference/orm/relations/has-many-through#grouplimit