Skip to content

Commit 4c8ecca

Browse files
committed
CXX-516 support nolock in eval
1 parent 3a08d9a commit 4c8ecca

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/mongo/client/dbclient.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,11 +1458,15 @@ namespace mongo {
14581458
return result.obj();
14591459
}
14601460

1461-
bool DBClientWithCommands::eval(const string &dbname, const string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args) {
1461+
bool DBClientWithCommands::eval(const string &dbname, const string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args, bool nolock) {
14621462
BSONObjBuilder b;
14631463
b.appendCode("$eval", jscode);
1464-
if ( args )
1464+
if ( args ) {
14651465
b.appendArray("args", *args);
1466+
}
1467+
if ( nolock ) {
1468+
b.appendBool("nolock", true);
1469+
}
14661470
bool ok = runCommand(dbname, b.done(), info);
14671471
if ( ok )
14681472
retValue = info.getField("retval");

src/mongo/client/dbclientinterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,12 +1075,13 @@ namespace mongo {
10751075
retValue return value from the jscode function.
10761076
args args to pass to the jscode function. when invoked, the 'args' variable will be defined
10771077
for use by the jscode.
1078+
nolock if true, the server will not take a global write lock when executing the jscode.
10781079
10791080
returns true if runs ok.
10801081
10811082
See testDbEval() in dbclient.cpp for an example of usage.
10821083
*/
1083-
bool eval(const std::string &dbname, const std::string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args = 0);
1084+
bool eval(const std::string &dbname, const std::string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args = 0, bool nolock = false);
10841085

10851086
/** validate a collection, checking for errors and reporting back statistics.
10861087
this operation is slow and blocking.

0 commit comments

Comments
 (0)