0

Previously I asked about getting random users. I was able to use page request and just request certain page with certain page size. And I needed to get the total number of users first. And that went well.

I now realized that that was the wrong question. I actually need to get random number of custom objects. It doesn't appear that I could use the same method. There is no paged request for custom object, nor do I know how to get the total number of objects. How would I be able to do it?

EDIT:

I've just noticed that parameter can have count and limit. I'll try it out.

EDIT 2: I can't figure out how to put the parameter count in. I tried

[QBCustomObjects objectsWithClassName:NSStringFromClass([self class])
                      extendedRequest:[@{@"gender": 0, @"count": [NSNull null]} mutableCopy]
                             delegate:proxy];

What I was trying to do was to find the count for all in the table where gender is 0. But it returned all records that matched.

Community
  • 1
  • 1
huggie
  • 17,587
  • 27
  • 82
  • 139

1 Answers1

0

count should be used without any other params

[QBCustomObjects objectsWithClassName:NSStringFromClass([self class])
                      extendedRequest:[@{@"count": @"1"} mutableCopy]
                             delegate:proxy];

This query will return count of records

Rubycon
  • 18,156
  • 10
  • 49
  • 70
  • So unlike SQL where you can designate a where clause and then find the count, here I cannot do so? That's fine. I can split the gender into two different tables. BTW, how efficient is the extended query? We're not dealing with database directly here so we cannot control where the index is, so I wonder how efficient extended query request could be. I don't want to unnecessarily strain the system. – huggie Nov 29 '13 at 00:48