You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Doc: how to pass filter/where argument to find and findOne #47
I can see you were not able to read the generated API docs (strongloop/loopback-sdk-angular-cli#7). I am wondering: if our main documentation included samples how to query models via the generated API, would it help you to not run into this issue? (Have you read that doc page at all?)
OK, I think I see the issue here. Angular client must use the REST API for queries (vs. the Node API used on server). The REST API requires using the literal "filter" in the query string, but Node API does not. In this case, you are passing "stringified JSON", which I've been meaning to add to the docs for a while, anyway...
I think your example is incorrect, this the query that works for me:
GET /api/activities/findOne?filter={ where: { id: '53825529' } }
However, it's entirely possible that both my and your versions are correct. I know the query string parser supports a lot of different flavours.
Should I add a note somewhere in the Angular SDK docs? If so, where? I couldn't find an obvious place.
I'd say this should be added to the auto-generated API docs. Which is not possible at the moment, because the filter argument is of a generic object type, thus the code generator has no way to tell that it is a special type.
Activity
bajtos commentedon May 26, 2014
Hi @pbrain19, thank you for reporting this issue, we appreciate you are willing to invest your time to make LoopBack a better framework.
Now I need more information to reproduce your problem, at least the angular code of your
filterandfindOnerequest(s).Possibly related: strongloop/loopback#279.
bajtos commentedon May 26, 2014
Moving here the conversation from strongloop/loopback-sdk-angular-cli#6.
That URL suggests you are calling the API incorrectly.
I can see you were not able to read the generated API docs (strongloop/loopback-sdk-angular-cli#7). I am wondering: if our main documentation included samples how to query models via the generated API, would it help you to not run into this issue? (Have you read that doc page at all?)
pbrain19 commentedon May 26, 2014
http://docs.strongloop.com/display/LB/Querying+models
Please look at example... It does not say anything about adding filter inside query
bajtos commentedon May 26, 2014
Those examples are showing how to use the server-side (node.js) API.
The SDK for AngularJS has a different API:
http://docs.strongloop.com/display/DOC/AngularJS+JavaScript+SDK
/cc @crandmck FYI. I am not sure if there is a reasonable way how to distinguish between client-side and server-side APIs in our docs.
pbrain19 commentedon May 26, 2014
The angular doc should be enhanced a bit... Just a tiny bit to help beginners
[-]Improper calls being made by sdk[/-][+]Doc: how to pass filter/where argument to `find` and `findOne`[/+]raymondfeng commentedon Sep 2, 2014
@crandmck Can you help enhance the docs?
crandmck commentedon Sep 3, 2014
OK, I think I see the issue here. Angular client must use the REST API for queries (vs. the Node API used on server). The REST API requires using the literal "filter" in the query string, but Node API does not. In this case, you are passing "stringified JSON", which I've been meaning to add to the docs for a while, anyway...
I added the a description here: http://docs.strongloop.com/display/LB/Querying+models#Queryingmodels-UsingstringifiedJSONinRESTqueries. @raymondfeng Can you please confirm that I got it right?
I also added links from each filter article, e.g. http://docs.strongloop.com/display/LB/Where+filter.
Should I add a note somewhere in the Angular SDK docs? If so, where? I couldn't find an obvious place.
bajtos commentedon Sep 4, 2014
I think your example is incorrect, this the query that works for me:
However, it's entirely possible that both my and your versions are correct. I know the query string parser supports a lot of different flavours.
I'd say this should be added to the auto-generated API docs. Which is not possible at the moment, because the
filterargument is of a genericobjecttype, thus the code generator has no way to tell that it is a special type.crandmck commentedon Sep 10, 2014
OK, I made that correction and clarified the text a bit. I believe this can be closed.