diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-12-03 17:11:24 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-12-03 17:11:24 -0500 |
commit | 5d8ca55f47ab04a8dd0214351137ec6f78e52c56 (patch) | |
tree | 68b6d34bc4a0e29070f74bf0d7dcb5896a048cd4 /db/dbhelpers.h | |
parent | a5880774b5691d07f1f22c382fbb825c3b09c950 (diff) | |
download | mongo-5d8ca55f47ab04a8dd0214351137ec6f78e52c56.tar.gz |
some more helpers for querying
Diffstat (limited to 'db/dbhelpers.h')
-rw-r--r-- | db/dbhelpers.h | 17 |
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". |