Hi,
I am following the Social App blog post (https://backendless.com/how-to-build-social-app-backend-backendless-1/)
From the post.likes relation column (which is a one-to-many to users table) we want to load only the users.objectId property
This is my query on the Posts table (notice the “likes.objectId as likedBy” property)
val queryBuilder = DataQueryBuilder.create()
queryBuilder.whereClause = "ownerId= '$userId' OR ownerId in (Users[objectId='$userId'].following.objectId)"
queryBuilder.addProperties("title", "content", "image", "location",
"locationName", "created", "updated", "ownerId", "objectId",
"postOwner.name as postUserName",
"postOwner.imageUrl as postUserImage",
"Count(likes) as totalLikesCount",
"likes.objectId as likedBy"
).setGroupBy("objectId")
.setSortBy("created desc")
.setRelated("postOwner")
.setRelated("likes")
but all likes/user properties are loaded
{
"content": "My First Post",
"created": "Oct 15, 2020 09:48:03",
"image": "https://backendlessappcontent.com/...",
"likes": [
{
"properties": {
"lastName": "-",
"lastLogin": "Oct 15, 2020 13:26:28",
"userStatus": "ENABLED",
"created": "Oct 11, 2020 08:01:50",
"county": "HUNEDOARA",
"ownerId": "88F9E311-9B24-4B47-9EDC-43AD6B1A7BB7",
"socialAccount": "BACKENDLESS",
"firstName": "-",
"___class": "Users",
"blUserLocale": "en",
"updated": "Oct 11, 2020 08:07:17",
"email": "costi@leadingedge.ro",
"objectId": "88F9E311-9B24-4B47-9EDC-43AD6B1A7BB7"
}
}
],
"location": {
"x": 22.9072331,
"y": 45.7678128,
"srs": "WGS84"
},
"objectId": "A8A286BB-F389-4653-A7A8-EE2EF2FCE0FC",
"ownerId": "917361FD-D6F7-4881-8250-1F59370BBEF1",
"title": "First Post",
"totalLikesCount": 3
}
We would however expect to see only the object id property, like this
{
"content": "My First Post",
"created": "Oct 15, 2020 09:48:03",
"image": "https://backendlessappcontent.com/...",
"likes": [
{
"properties": {
"objectId": "88F9E311-9B24-4B47-9EDC-43AD6B1A7BB7",
}
}
],
"location": {
"x": 22.9072331,
"y": 45.7678128,
"srs": "WGS84"
},
"objectId": "A8A286BB-F389-4653-A7A8-EE2EF2FCE0FC",
"ownerId": "917361FD-D6F7-4881-8250-1F59370BBEF1",
"title": "First Post",
"totalLikesCount": 1
}
Hope this makes sense and any help is much appreciated
Thanks
Constantin