I have a forum application with a forums table on top, having relations to the posts table. The 2 step approach works pretty well as long as I don’t use aggregates. The posts table has a relationsshipt to the users table in field “likes”. So I want to return the number of likes with each post. Unfortunately, I only get back one record with the overall number of likes for ALL posts. The GROUP BY doesn’t seem to work here … Any idea?
const queryWithPosts = Backendless.LoadRelationsQueryBuilder.create()
.setPageSize(5)
.setProperties([
‘description’,
‘created’,
‘objectId’,
‘ownerId’,
‘locationId’,
‘Count(likes) as totalLikesCount’,
])
.setGroupBy('objectId')
.setSortBy('locationId DESC')
queryWithPosts.setRelationName('posts');
const forumPosts = await Backendless.Data.of('forums').loadRelations(
forumId,
queryWithPosts )