Page 1 of 1

Inner join in appery.io

Posted: Fri Feb 06, 2015 11:59 am
by anshika

i need to fetch data from two tables on the basis :
i have two tables "questions" and "answers" and i need to show number of answers per question on the ui screen (one to many relation);

i had tried the following:
1) i had invoked this

// Get the user with a given username from the database
var XHRResponse = XHR.send("GET", "{database_url}/collections/AnswersComments", {

Code: Select all

 "parameters": { 
   "where": '{"pid._id": "54d49a56e4b0cc014944f74a"}' 
 } 

});

from the service("questions_list_service" success event) .

2) called this service ("answer_list_service" before send event )on "page show" and "page load " events

i also need to make a "ul", " li" view for questions and it answers on the same screen on page load


Inner join in appery.io

Posted: Fri Feb 06, 2015 1:36 pm
by Evgene Karachevtsev

Hello!

1) You should add a question pointer column to your answers collection
2) Each time you save a new answer please set it with id of question entity
then you will be able to make query calls to answers collection with id of question and get your number


Inner join in appery.io

Posted: Fri Feb 06, 2015 1:42 pm
by anshika

Hi
Evgene Karachevtsev,

i had already done this to fetch the data from answer table in refence with question table id

but now i am looking forward for fetching questions and answer both simultaneously
for example if i call questions table list i should also get the counts (answers per question) displayed against each question


Inner join in appery.io

Posted: Mon Feb 09, 2015 5:28 am
by anshika

Hi can you please reply if you know the solution


Inner join in appery.io

Posted: Tue Feb 10, 2015 1:37 am
by Yurii Orishchuk

Hi Anshika,

Unfortunatly "join" is not supports currently.

If your base entity contains pointer to other table - you can include it to the base entity REST response with "include" parameter. See more about it here: http://devcenter.appery.io/documentat...

Also you can implement "join" logic you need with "server code".
More details about server code here: http://devcenter.appery.io/documentat...

Regards.