Support Topics Documentation Slack YouTube Blog

How to expand on the query given in the documentation


(SnakeEyes) #1

Hello,
I am looking at the example provided in docs https://backendless.com/docs/android/data_search_with_subquery.html

where you have users, blogPost, and comments. Using the same example, how can I achieve the following:

Get all blogs (objId and blog text) with the count of the comments made on each blog, where author is user with email ‘xxx@example.com’

So Ideally, I would get multiple rows/maps of the following
Blog.objId, Blog.Text, Count(comment)

Thank you


(Sergey Chupov) #2

I guess you can use where clause author.email = 'xxx@example.com' and properties list objectId, text, count(comment.objectId). See also this page for count aggregation function documentation: https://backendless.com/docs/rest/data_count.html


(SnakeEyes) #3

Just another followup question on that. I know how I would do count on the comments if I am doing query on the comment table as per your example. But in my above example, the query is issued against the BlogPosts, would I still be able to get the comments count where the comment is 1:1 to Blog post (not the other way around). If I use your suggestion above, there is no comment column in the blog posts, so how does the api know I am looking for count on comments that are mapped to blog posts? Does my question make sense?