Page 1 of 1

where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 2:01 am
by adith visnu

i want to retrieve data from collections, and this is my javascript codes

var id = localStorage.getItem('id_device');

track.execute({ "data":{"where":'{"PIN":"usersdata":"addTracker","idPenambah":"'+id+'"}}'}});

Image

i want to retrieve data from 'usersdata' where in 'addTracker' have condition too.

*PIN in usersdata collections
*idPenambah in addTracker collections

Thankyou


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 4:46 am
by Yurii Orishchuk

Hi Adith,

Please use following code instead of yours:

pre

var whereObject = {"PIN":"usersdata", "idPenambah": id};

track.execute({data: {where: JSON.stingify(whereObject)} });

/pre

Also i see you have some confuse in queries. Thus please take a look about queries here: http://devcenter.appery.io/documentat...

Regards.


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 5:05 am
by adith visnu

hi Yurii!
thanks for the answer. but there is an error.
that is : Uncaught TypeError: undefined is not a function. its referer to JSON.stingfy(whereObject).


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 5:14 am
by Yurii Orishchuk

Adith,

Sorry this is a typo.

Here is right code:

pre

var whereObject = {"PIN":"usersdata", "idPenambah": id};
track.execute({data: {where: JSON.stringify(whereObject)} });

/pre

Regards.


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 5:59 am
by adith visnu

Hi yurii, nevermind for the typo.

could you explain your code?


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 6:57 am
by adith visnu

let me clear this questions.

its addTracker Collections
Image

and its usersdata collections
Image

i want to retrieve lat and lng from 'usersdata' which the PIN are retrieve idYangDiTrack from 'addTracker' collections


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 7:34 am
by adith visnu

let me makes my problem clearly

i want to retrieve :

Image

and my code is

track.execute({ "data":{"where":'{"PIN":"usersdata":"addTracker","idPenambah":"'+id+'"}}'}});

am i wrong?


where condition list. am i wrong ?

Posted: Tue Jul 15, 2014 9:51 pm
by Yurii Orishchuk

Hi Adith,

Nope, your code is not good. And will generate syntax error.

There is some things which is you need to know:

  1. You can not choose field to be returned in response. Whole entity will return.

  2. You can send request only to one collection. If you need information from two or more collections you need multiple requests.

  3. "Where" request parameter should be used when you need make some "search" in collection. See more about queries here: http://devcenter.appery.io/documentat...

  4. Also you can read about service execution(with JS code) here: http://devcenter.appery.io/documentat...

    Regards.


where condition list. am i wrong ?

Posted: Wed Jul 16, 2014 12:48 am
by adith visnu

Hi Yurii,

If i use your code above. its return null. I didn't know why.
And when i use multiple request as you said, it works..

I think this topics can you mark as "solved" topics

Thanks for the explain Yurii

Regards


where condition list. am i wrong ?

Posted: Wed Jul 16, 2014 1:38 am
by Yurii Orishchuk

Adith,

Thanks for this update.

Regards.