0

I am trying to write a query that joins two of my MobileServiceTables in my Azure Cloud Portal.

Currently here is my code.

List<Post> followTable = mPostTable.where().field("userId").ne(mUser.getUserId()).orderBy("createdAt", QueryOrder.Descending).execute().get();
            mPostTable.where().field("userId").ne(mUser.getUserId()).orderBy("createdAt", QueryOrder.Descending).execute().get();
            final List<Post> returnTable = new ArrayList<Post>();
            for(Post p : followTable){
                if(doesFollowingExist(mUser.getUserId(), p.getId()).size() > 0 
                && !doesFollowingExist(mUser.getUserId(), 
                p.getId()).get(0).isRemoved()){
                    returnTable.add(p);
                    p.setFollowed(true);
                }
            }

I first find all posts that the user did not write. Then, I run a quick test to see if the user has followed the post. If he has, then it will add it to a new list. However, this method of doing it requires me to look through every single post, then do the follow check on each one individual.

Obviously, this is the wrong way to do it and it takes forever. What I am asking is: How do I join these two tables so that I can get all posts that user has followed in one query? I cant seem to find a way to do it.

1 Answers1

0

The Azure Mobile Apps client SDK just allow you to do some simple operations which not include the operation like join. If you want to do that, you need to create a custom api at the backend and call the custom api at the mobile end like android app.

There is a similar SO thread Azure mobile app query inner join with java, which you can refer to my answer to know how to do.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43