Page 1 of 1

Complex Database Connections

Posted: Tue Jan 20, 2015 1:46 am
by viperciyes

Hi,

I have a database with two collections. On my app page, I have one "select" control, and I use it to list classnames from my classes collection. Now, after I choose one, I want to list all students with the same classname(I already did the pointer thing in the database) in a "list" control right below the "select" control. How will I tell the service which item is selected in the "select" control?


Complex Database Connections

Posted: Tue Jan 20, 2015 4:28 am
by Yurii Orishchuk

Hello,

Please follow these steps:

  1. add "list/query" service datasource on the page.

  2. open "before send" mapping.

  3. find "where" request parameter and click "JS" on this parameter.

  4. populate it with following JS code:

    pre

    //Note you need to replace "selectName" with your select component name.
    var classValue = Apperyio("selectName").val();

    //Where "class" is your pointer field.
    var whereObject = {"class": {"$inQuery": {_id: classValue } } };

    return JSON.stringify(whereObject);

    /pre

    Regards.


Complex Database Connections

Posted: Tue Jan 20, 2015 12:59 pm
by viperciyes

is there a video or tutorial about this? I find it difficult to do that.


Complex Database Connections

Posted: Tue Jan 20, 2015 1:23 pm
by Alena Prykhodko