Skip to content

Commit

Permalink
return really the bson data for each documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Lebel committed Nov 14, 2013
1 parent b72a203 commit 935d810
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Sources/MODCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,26 @@ - (MODQuery *)findWithCriteria:(NSString *)jsonCriteria fields:(NSArray *)fields
query = [_mongoDatabase.mongoServer addQueryInQueue:^(MODQuery *mongoQuery) {
if (!mongoQuery.canceled) {
NSMutableArray *documents;
NSMutableArray *bsonData;
NSMutableArray *allBsonData;
NSData *bsonData;
MODCursor *cursor;
MODSortedMutableDictionary *document;
NSError *error = nil;

documents = [[NSMutableArray alloc] initWithCapacity:limit];
bsonData = [[NSMutableArray alloc] initWithCapacity:limit];
allBsonData = [[NSMutableArray alloc] initWithCapacity:limit];
cursor = [self cursorWithCriteria:jsonCriteria fields:fields skip:skip limit:limit sort:sort];
while ((document = [cursor nextDocumentWithBsonData:nil error:&error]) != nil) {
while ((document = [cursor nextDocumentWithBsonData:&bsonData error:&error]) != nil) {
[documents addObject:document];
[allBsonData addObject:bsonData];
}
if (error) {
mongoQuery.error = error;
}
[mongoQuery.mutableParameters setObject:documents forKey:@"documents"];
[mongoQuery.mutableParameters setObject:bsonData forKey:@"dataDocuments"];
[mongoQuery.mutableParameters setObject:allBsonData forKey:@"dataDocuments"];
[documents release];
[bsonData release];
[allBsonData release];
}
[self mongoQueryDidFinish:mongoQuery withCallbackBlock:^(void) {
callback([mongoQuery.mutableParameters objectForKey:@"documents"], [mongoQuery.mutableParameters objectForKey:@"dataDocuments"], mongoQuery);
Expand Down

0 comments on commit 935d810

Please sign in to comment.