//
//  Queries.m
//  drachma
//
//  Created by Niko Matsakis on 2/6/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "Queries.h"
#import "OACoreData.h"

@implementation NSManagedObjectContext (Queries)

#pragma mark -
#pragma mark Queries

- (NSArray*) expenses
{
    return [self allObjectsOfEntityType:@"Expense"];
}

- (NSArray*) expensesBefore:(NSDate*)date
{
    DEFINEARRAYQUERY(@"Expense", @"date <= %@", date);
}

- (NSArray*) payeeCompletions:(NSString*)prefix
{
    //    return [self objectsOfEntityType:@"Payee" 
    //                   matchingPredicate:[NSPredicate predicateWithFormat:@"name BEGINSWITH[cd] %@", prefix]];
    DEFINEARRAYQUERY(@"Payee", @"name BEGINSWITH[cd] %@", prefix);
}

@end
