Closed jasonsilberman closed 10 years ago
+1. I'd add it would be great if it did not negate the ability to add an ORDER BY
per query through appending or querying without the order/replacing the default. That would add flexibility to allow for a default but specific queries elsewhere without the default.
[namely pulling from Rails' default_scope]
The concept of a default order-by would be somewhat inconsistent or vague, since it would only apply to certain queries and not others. (At least, without getting into the hacky business of trying to parse people's queries to determine whether they already contain a valid ORDER BY
, which is a business I'd rather not get into.) I'd rather avoid it if possible.
You can already override allInstances
in each model class, e.g. in the Person class:
+ (NSArray *)allInstances
{
return [self instancesWhere:@"1 ORDER BY pos"];
}
Is this enough?
I can definitely understand the hesitation there. I guess you're right on just overriding.
That makes sense, thanks!
Is there a way you could do something like this?
Then on queries such as
allInstances
it would automatically sort the array by that?Maybe it could work by just appending that string?
Thanks!
P.S. I am totally loving this so far & am planning to use this in an upcoming app!