SugarRecord/SugarRecord — pull request #87 by twobitlabs (2014-12-18 18:51:12+00:00)
Title: Add count() method to entities and optimize Core Data implementation

Although the SugarRecord wiki lists a `count()` method under "Objects querying", there is no such method--you have to call `all().count()`.

In Core Data, this is inefficient, as it loads all instances of the entity and then counts them. I've added a `count()` method to `SugarRecordObjectProtocol` as is currently documented, so it can be more conveniently called directly from an object type (e.g., SomeObjectClass.count()).

Also optimized the Core Data implementation of `count()` to use `NSManagedObjectContext.countForFetchRequest()` which invokes a count(*) query on the data store instead of loading the entities and counting them.