Edwin Schravesande6028557
Posts: 0
Joined: Tue Jul 09, 2013 2:44 pm

using a where clause from the mapping tool

Basically what I'm trying to do is to query my database, using your sofisticated mapping tool instead of my quite-lacking JavaScript skills. I can't get it to work, but after some hours I at least cornered my problem, could you help me out from here?

So I put up a service that query's my userdata (not a collection but the usertable). The login works fine, I get my sessionTokens and id, store them local. Now I wanna get names and userlevels out.

First construction, just to get closer, is to try to use the URL-field in the settings tab. It works totally fine if I post
{database_url}/users/5140eb66e4b0fa3619eaade8
But the whole point of course is, to get it to work for all users.
I tried {database_url}/users/{_id} but apperently it's not that simple. Why not by the way? (question1)

So second construction, working from the way the query services are organized, it appears I better put up an extra 'where' variable in the request, naming it {"_id":"51cd9521e4b0901056be9221"}. (Still just to get closer, in the end the actual id should be varying from case to case, but if this particular example doesn't work, that's just a next step)

So this first appears to work fine, testing it in the test-tab, but the response is not actually mapped, testing the whole procedure. The difference is two brackets.

The first construction responses
{
content
}

The second construction responses
[
{
content
}
]

I can confirm this from both the test-tab and the Chrome-Console

The second construction fails to map the response correct in my test-setting.
Could you please explain where did I go wrong and how to solve this?

BTW: I read this post, https://getsatisfaction.com/apperyio/..., explaining comparable problems for people who script this whole thing up. But the provided solutions there didn't get me further.

Thnx anyone for helping me taking the next step.

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

using a where clause from the mapping tool

This works fine for me (both questions). Could you give us public link to your project? http://docs.appery.io/documentation/s...

Edwin Schravesande6028557
Posts: 0
Joined: Tue Jul 09, 2013 2:44 pm

using a where clause from the mapping tool

What is regarded fine? Is a response [{content}] fine in general, cause in my particular case only the response {content} seems to be working.

You can see my loginscreen at http://appery.io/app/view/fb9a1979-ee..., and test it with user=123456711 pw=11. It doesn't produce any front-end alarms, but it should be storing variables local, in this case 'klas', 'userlevel' and 'naam'. This information is indeed in the response of the last RESTcall you can see in the console, but the extra brackets or whatever prevents it from loading correct in the local variables.

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

using a where clause from the mapping tool

Hi Edwin,

Question 1

for using {database_url}/users/{id} you need to specify request parameter id. Appery.io code parse that url and try to find any option to replace {something} from request parameters with same name.

Question 2

The first construction responding with one object.

The second construction responding with array of objects, always. This happens because where can creates more difficult queries then querying one specific object. So for more universal case, this query always returning array.

For mapping arrays you can use special response parameter name $ or simply generate response parameters map from test call.

Return to “Issues”