2

I have dbobject like:

#import <Foundation/Foundation.h>
#import <DBAccess/DBAccess.h>

@interface GroupMember : DBObject

@property (strong) NSString *firstname;
@property (strong) NSString *lastname;
@property (strong) NSString *_id;

@end

How can I get an array of all group member's firstname? Thanks in adv.

Dhvl B. Golakiya
  • 239
  • 1
  • 3
  • 10
  • DBAccess v1.6.7 now has a distinct call thanks to your question and feedback. http://www.db-access.org/downloads – Adrian_H Jun 16 '15 at 11:48

1 Answers1

1

Because you are not dealing with SQL but with whole objects, this requires a little bit of working round the problem, but it is possible.

NSDictionary* resultsGroupedByFirstName = [[GroupMember query]  groupBy:@"firstname"];
NSArray* names = resultsGroupedByFirstName.allKeys;

This is a fairly expensive call as it is having to do a fair amount of work in the background. Although it is optimised slightly by using an index to detect changes in the column.

This should do the trick.

NOTE:

DBAccess v1.6.7 now has a distinct call thanks to your question and feedback. http://www.db-access.org/downloads

Adrian_H
  • 1,548
  • 1
  • 14
  • 27