From 5d8ca55f47ab04a8dd0214351137ec6f78e52c56 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Thu, 3 Dec 2009 17:11:24 -0500 Subject: some more helpers for querying --- db/dbhelpers.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'db/dbhelpers.h') diff --git a/db/dbhelpers.h b/db/dbhelpers.h index fc0013dedcc..69fbb6ab06d 100644 --- a/db/dbhelpers.h +++ b/db/dbhelpers.h @@ -24,6 +24,21 @@ namespace mongo { + class CursorIterator { + public: + + CursorIterator( auto_ptr c ); + ~CursorIterator(); + + BSONObj next(); + bool hasNext(); + private: + auto_ptr _cursor; + }; + + /** + all helpers assume locking is handled above them + */ struct Helpers { /* ensure the specified index exists. @@ -51,6 +66,8 @@ namespace mongo { static bool findById(const char *ns, BSONObj query, BSONObj& result ); + static auto_ptr find( const char *ns , BSONObj query = BSONObj() , bool requireIndex = false ); + /* Get/put the first object from a collection. Generally only useful if the collection only ever has a single object -- which is a "singleton collection". -- cgit v1.2.1