Objcmongodb 检索整个集合,然后将其添加到字典中

Objcmongodb 检索整个集合,然后将其添加到字典中,objcmongodb,Objcmongodb,我可以从mongodb中的集合中检索单个条目,但无法检索整个集合。在我检索完整个收藏后,我想把它放到字典里。检索整个集合应该很简单。我已经测试了在shell中用于完成任务的各种命令,但一旦转换为objective-c,所有命令都不成功 //Message Retrieval BSONDocument *resultDoc = [collection findAllWithError:&error]; NSDictionary *result = [BSONDecod

我可以从mongodb中的集合中检索单个条目,但无法检索整个集合。在我检索完整个收藏后,我想把它放到字典里。检索整个集合应该很简单。我已经测试了在shell中用于完成任务的各种命令,但一旦转换为objective-c,所有命令都不成功

   //Message Retrieval
    BSONDocument *resultDoc = [collection findAllWithError:&error];
    NSDictionary *result = [BSONDecoder decodeDictionaryWithDocument:resultDoc];
    NSLog(@"fetch result: %@", result);
-findAllWithError:返回文档数组:

NSArray *results = [collection findAllWithError:&error];
for (BSONDocument *resultDoc in results) {
    NSDictionary *result = [BSONDecoder decodeDictionaryWithDocument:resultDoc];
    NSLog(@"fetch result: %@", result);
}

@noa我知道如何使用findOneWithPredicate:predicate只获取一个条目,但是有没有办法只执行一个collection.find,以便它返回集合下的所有项?我已经浏览了ObjCMongodb的功能,但没有任何东西能引起我的注意。是的,它是-findAllWithError:。@noa尝试使用上面更新的代码