Hi !
Can't get filter in deep properties to work.
A basic example :
Here's the db :
{
"posts": [
{
"id": 1,
"title": "Post 1",
"author": "author1"
},
{
"id": 2,
"title": "Post 2",
"author": "author2"
}
],
"comments": [
{
"id": 1,
"body": "some comment",
"postId": 1
},
{
"id": 2,
"body": "some comment again",
"postId": 1
},
{
"id": 3,
"body": "some comment for bis post",
"postId": 2
}
]
}
When I ask for /comments?post.author=author1 (with or without _expand=post), I still get all the comments when I expect to only get comments 1 & 2 .
The relantionship comments -> post seems ok, here's the /comments?_expand=post response :
[
{
"id": 1,
"body": "some comment",
"postId": 1,
"post": {
"id": 1,
"title": "Post 1",
"author": "author1"
}
},
{
"id": 2,
"body": "some comment again",
"postId": 1,
"post": {
"id": 1,
"title": "Post 1",
"author": "author1"
}
},
{
"id": 3,
"body": "some comment for bis post",
"postId": 2,
"post": {
"id": 2,
"title": "Post 2",
"author": "author2"
}
}
]
Any idea ?
I have confirmed this issue using the jsonplaceholder.typicode.com site. According to the documentation
Use . to access deep properties
GET /posts?title=json-server&author=typicode
GET /posts?id=1&id=2
GET /comments?author.name=typicode
the following should return only the posts written by username "Bret":
http://jsonplaceholder.typicode.com/posts?users.username=Bret
Instead, the call returns all posts. Either the documentation is incorrect or there is a bug.
EDIT: For completeness, I also tested the following:
http://jsonplaceholder.typicode.com/posts?user.username=Bret
It also returns all posts.
Any update for resolving this issue?
Hi,
Have a look at http://jsonplaceholder.typicode.com/users and http://jsonplaceholder.typicode.com/users?address.street=Kulas%20Light
It seems the the filter of deep objects are only intended if there are nested objects.
Regards
Stefan du Preez
Same problem here.
Wanted the same thing! Would be a nice feature to add so not have to write own middleware..
I have similar issue and i am getting complete records as mentioned even after filtering: https://stackoverflow.com/questions/52041059/how-to-mock-json-server-with-deep-filtering. Please help
How is this not resolved? Spent a few hours only to find that the documentation is wrong.
Very frustrating 馃槩 @typicode
same problem here.
Any updates?
Most helpful comment
I have confirmed this issue using the
jsonplaceholder.typicode.comsite. According to the documentationthe following should return only the posts written by username "Bret":
Instead, the call returns all posts. Either the documentation is incorrect or there is a bug.
EDIT: For completeness, I also tested the following:
It also returns all posts.