I am not good with Obj-C/Swift, so instead of showing a coding sample, I will describe how to achieve this:
If you need to determine object count or entities related to another object, you can run the following query (with the “find” request) against the Comment table with PageSize set to 1 (yes, you will load only one object, but the response will also tell you how many total “child” objects are available on the server:
Post[comments].objectId = ‘parent-post-objectId’
where:
comments - the name of the relation column in the Post table
parent-post-objectId - objectId of the Post object for which you need to get the comments
The response will be an instance of BackendlessCollection, which contains the “totalObjects” property. The property will give you the total number of comments for the post.
Here in my current situation is - i am loading all the post from Post table (i have to show the comments count in the first page) - while loading the Post table i have to get the comment count, not to send a separate request for each post to get the comments,
As per option 1 : You mean manually i have to update the count property in Post table whenever a new comment added for a post?
If you want to avoid multiple calls to get the values, then it is one of the options to do that.
As for the auto-increment at the database level, there is no built-in mechanism to do it. It can be done with a custom event handler (Cloud Code) though. Another option is to maintain a separate counter using the following API (but that will not help with reducing the number of API calls): https://backendless.com/documentation/utilities/ios/ut_atomic_counters_ios.htm