Extract data from multiple tables

I need to extract data from 2 different tables in the database, using the same for loop. Here’s my code:

JS code:

.controller('GuBookingsCtrl', function($scope, $state) {
  var init = function() {
    var user = $state.params.user;
    $scope.res = [];
    $scope.hotel = [];
    var whereClause = "guestID = '" + user.objectId + "'";
    var queryBuilder = Backendless.DataQueryBuilder.create().setWhereClause( whereClause );
    Backendless.Data.of("Bookings").find( queryBuilder )
      .then(function(foundHotels) {
        $scope.res = foundHotels;
        for (var i=0;i<$scope.res.length;i++){
          $scope.hotel = Backendless.Data.of("Hotels").findByIdSync( {objectId: $scope.res.hotelID} );
      .catch(function(error) {
        console.log("error" + error.message);
  $scope.doRefresh = function () {
      $scope.$broadcast ('scroll.refreshComplete');

  $scope.cancel = function() {
    console.log("cancel clicked");

HTML code:

&lt;ion-view view-title=&quot;Your Bookings&quot; ng-controller=&quot;GuBookingsCtrl&quot;&gt;
  &lt;ion-content class=&quot;padding&quot;&gt;
    &lt;ion-refresher pulling-text=&quot;Pull to refresh...&quot; on-refresh=&quot;doRefresh()&quot;&gt;
    <ul class="list">
        &lt;li ng-repeat=&quot;r in res track by $index&quot; r=&quot;r&quot; hotel=&quot;hotel&quot; class=&quot;item item-button-right&quot;&gt;
          &lt;p&gt;{{r.checkin}} to {{r.checkout}}&lt;/p&gt;
          &lt;button class=&quot;button button-positive&quot; ng-click=&quot;cancel()&quot;&gt;

Can this be achieved in the HTML loop that is present?

Hi Saurav,

Helping to write code using third-party frameworks is not something we do on a free support forum, but a part of our consulting services. Looks like your code to retrieve the objects from Backendless is correct, so there’s nothing we could help you here more.