-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
How to get a nested resource without getting the parent? #13
Comments
You can create new instances manually. See on README. let post = new Post()
post.id = 123
// or just pass as a payload
let post = new Post({id: 123})
// of course you can pass any other params Then.. // GET /posts/123/comments
let comments = await post.comments().get() Make sure |
Awesome, thanks! This method seems to work with const User = new User({id: 1})
const Post = await User.posts().find(2) This fires "/posts/2" instead of "/users/1/posts/2". |
The For nested resources you should always use As described on README you can use another methods before
|
Okie dok. Is there some philosophy behind the |
My bad, you are right. I Will look it further.
—
Robson Tenório
Em 4 de jun de 2018, à(s) 17:47, Dylan Chapman <notifications@github.com> escreveu:
… Okie dok. Is there some philosophy behind the find() method not being able to be used with nested resources? I thought nested resources with multiple identifiers was a common REST API pattern?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Find method respects relationships, fixes #13
@Dylan-Chapman Now you can do this const User = new User({id: 1})
const Post = await User.posts().find(2) Just upgrade to |
Say I want to get the posts for ID user 1, "/users/1/posts". However, I have no need to get the actual user object, "/users/1" first. Is there a built-in way to do this? I didn't have luck trying to run
User.find(1).posts().get()
for example. Any other way to accomplish this without the unneeded API call?The text was updated successfully, but these errors were encountered: