summaryrefslogtreecommitdiff
path: root/db/dbhelpers.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-12-03 17:11:24 -0500
committerEliot Horowitz <eliot@10gen.com>2009-12-03 17:11:24 -0500
commit5d8ca55f47ab04a8dd0214351137ec6f78e52c56 (patch)
tree68b6d34bc4a0e29070f74bf0d7dcb5896a048cd4 /db/dbhelpers.h
parenta5880774b5691d07f1f22c382fbb825c3b09c950 (diff)
downloadmongo-5d8ca55f47ab04a8dd0214351137ec6f78e52c56.tar.gz
some more helpers for querying
Diffstat (limited to 'db/dbhelpers.h')
-rw-r--r--db/dbhelpers.h17
1 files changed, 17 insertions, 0 deletions
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<Cursor> c );
+ ~CursorIterator();
+
+ BSONObj next();
+ bool hasNext();
+ private:
+ auto_ptr<Cursor> _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<CursorIterator> 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".