summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbhelpers.h
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-05-29 15:36:28 -0400
committerMathias Stearn <mathias@10gen.com>2014-05-30 12:10:16 -0400
commita78d754b67040c19714bc4696dd7feb5ce10d412 (patch)
treeaaf640483eff976ff22fdaceb9ebfa78f7659af2 /src/mongo/db/dbhelpers.h
parent4edbe14669b7804180d8b58549e257ceb679bb1d (diff)
downloadmongo-a78d754b67040c19714bc4696dd7feb5ce10d412.tar.gz
SERVER-13641 Plumb OperationContext through to getCollection and all Helpers
Diffstat (limited to 'src/mongo/db/dbhelpers.h')
-rw-r--r--src/mongo/db/dbhelpers.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h
index 2cba18345d5..be0ca859248 100644
--- a/src/mongo/db/dbhelpers.h
+++ b/src/mongo/db/dbhelpers.h
@@ -79,29 +79,30 @@ namespace mongo {
@return true if object found
*/
- static bool findOne(Collection* collection,
+ static bool findOne(OperationContext* txn,
+ Collection* collection,
const BSONObj &query,
BSONObj& result,
bool requireIndex = false);
- static DiskLoc findOne(Collection* collection, const BSONObj &query, bool requireIndex);
-
- /**
- * have to be locked already
- */
- static std::vector<BSONObj> findAll( const std::string& ns , const BSONObj& query );
+ static DiskLoc findOne(OperationContext* txn,
+ Collection* collection,
+ const BSONObj &query,
+ bool requireIndex);
/**
* @param foundIndex if passed in will be set to 1 if ns and index found
* @return true if object found
*/
- static bool findById(Database* db, const char *ns, BSONObj query, BSONObj& result,
+ static bool findById(OperationContext* txn,
+ Database* db, const char *ns, BSONObj query, BSONObj& result,
bool* nsFound = 0, bool* indexFound = 0 );
/* TODO: should this move into Collection?
* uasserts if no _id index.
* @return null loc if not found */
- static DiskLoc findById(Collection* collection, const BSONObj& query);
+ static DiskLoc findById(OperationContext* txn,
+ Collection* collection, const BSONObj& query);
/** Get/put the first (or last) object from a collection. Generally only useful if the collection
only ever has a single object -- which is a "singleton collection".
@@ -110,11 +111,17 @@ namespace mongo {
@return true if object exists.
*/
- static bool getSingleton(const char *ns, BSONObj& result);
+ static bool getSingleton(OperationContext* txn, const char *ns, BSONObj& result);
static void putSingleton(OperationContext* txn, const char *ns, BSONObj obj);
static void putSingletonGod(OperationContext* txn, const char *ns, BSONObj obj, bool logTheOp);
- static bool getFirst(const char *ns, BSONObj& result) { return getSingleton(ns, result); }
- static bool getLast(const char *ns, BSONObj& result); // get last object int he collection; e.g. {$natural : -1}
+ static bool getFirst(OperationContext* txn, const char *ns, BSONObj& result) {
+ return getSingleton(txn, ns, result);
+ }
+
+ /**
+ * get last object int he collection; e.g. {$natural : -1}
+ */
+ static bool getLast(OperationContext* txn, const char *ns, BSONObj& result);
/**
* you have to lock
@@ -126,11 +133,6 @@ namespace mongo {
const BSONObj& o,
bool fromMigrate = false );
- /** You do not need to set the database before calling.
- @return true if collection is empty.
- */
- static bool isEmpty(const char *ns);
-
// TODO: this should be somewhere else probably
/* Takes object o, and returns a new object with the
* same field elements but the names stripped out.