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

.paginate can't call getRelated method #13

Closed
hlozancic opened this issue Apr 24, 2018 · 1 comment
Closed

.paginate can't call getRelated method #13

hlozancic opened this issue Apr 24, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@hlozancic
Copy link

hlozancic commented Apr 24, 2018

As the title says, it seams like it's impossible to transform related content if using .paginate() instead, for example, .collection().

This will work (but it will not return adonis pagination info):

const posts = await Posts.query().with('tags').paginate()
transform.include('tags').collection(posts, PostTransformer)

This will not work:

const posts = await Posts.query().with('tags').paginate()
transform.include('tags').paginate(posts, PostTransformer)

Error thrown is: model.getRelated is not a function... PostTransformer has this include:

includeTags(model) {
        return this.collection(model.getRelated('tags'), TagTransformer)
    }

Without .include() and defaultIncludes inside transformer, .paginate() works as expected

@rhwilr rhwilr added the bug Something isn't working label Apr 25, 2018
@rhwilr rhwilr changed the title Bug: .paginate can't call getRelated method .paginate can't call getRelated method Apr 25, 2018
@rhwilr
Copy link
Owner

rhwilr commented Apr 25, 2018

This issue was fixed by @spamoom in #14

@rhwilr rhwilr closed this as completed Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants