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

Include with filters REST URL #864

Closed
yagobski opened this issue Nov 25, 2014 · 11 comments
Closed

Include with filters REST URL #864

yagobski opened this issue Nov 25, 2014 · 11 comments

Comments

@yagobski
Copy link
Member

Hi,

I want to do include with filters based on REST REQUEST. Something like :

Albums?filter=[include][favorites]&filter[where][favorites.type]=abc

I am using MYSQL connector

Thanks

@violet-day
Copy link

In angular sdk

Albums.find({filter:{
  inculde://,
  where://
}})

@yagobski
Copy link
Member Author

Sorry but i want it using REST URL. Iam using CURL and PHP to parse API.

@mrbatista
Copy link

@yagobski error is equal characters after first filter.
Test Albums?filter[include][favorites]&filter[where][favorites.type]=abc
See http://docs.strongloop.com/display/public/LB/Include+filter for more information.
It seems that explorer generates broken url.

@yagobski
Copy link
Member Author

Test Albums?filter[include][favorites]&filter[where][favorites.type]=abc
NOT WORKING.

No information in doc pages

@violet-day
Copy link

@yagobski
You can also use stringified JSON format in a REST query.
For eaxmple:
query string:filter:{"where":{"name":"Post"},"include":["views","wfAss"]}

@johnsoftek
Copy link

Each filter needs an equals sign so the first part is:

Albums?filter[include]=favorites

I don't know how to filter an included model.

As @yagobski said, you could try stringified JSON:

Albums?filter={"include":{"relation":"favorites","where":{"type":"abc"}}}

@yagobski
Copy link
Member Author

This syntax not work with URL format

{"error":{"name":"Error","status":500,"message":"Relation "relation" is not defined for Album model","stack":"Error: Relation "relation" is not defined for Album model\n at processIncludeItem

@mrbatista
Copy link

@yagobski share your relations defined in .json file.

@yagobski
Copy link
Member Author

yagobski commented Dec 1, 2014

Any solution how to write this REST URL to filter inside included model?

Favorite.json

"relations": {
"albums": {
"type": "belongsTo",
"model": "Album",
"foreignKey": "objectId"
}
},

Album.json
"relations": {
"favorites": {
"type": "hasMany",
"model": "Favorite",
"foreignKey": "objectId"
}
},

@bajtos
Copy link
Member

bajtos commented Dec 4, 2014

Closing as a duplicate of #683 and/or #517.

@bajtos bajtos closed this as completed Dec 4, 2014
@yagobski
Copy link
Member Author

I still not found solution to this problem. #683 and/or #517 just referring to the same question but still no answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants