summaryrefslogtreecommitdiff
path: root/db/commands.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <ehorowitz@shopwiki.com>2008-09-14 13:16:50 -0400
committerEliot Horowitz <ehorowitz@shopwiki.com>2008-09-14 13:16:50 -0400
commit31eff8fb7cfa94783fcfb47622199a0ed27a0a53 (patch)
treee7ebaff7406aa75ea6c0fdcea6445c4413ea5e3a /db/commands.cpp
parent54668a9afecd39d21d77003bcc20991bddee2090 (diff)
downloadmongo-31eff8fb7cfa94783fcfb47622199a0ed27a0a53.tar.gz
can use this. instead of obj. for $where
scope passing for db.eval
Diffstat (limited to 'db/commands.cpp')
-rw-r--r--db/commands.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/db/commands.cpp b/db/commands.cpp
index 049b14e1dec..a9c393649d5 100644
--- a/db/commands.cpp
+++ b/db/commands.cpp
@@ -44,13 +44,14 @@ map<string,Command*> Command::commands;
bool dbEval(JSObj& cmd, JSObjBuilder& result) {
Element e = cmd.firstElement();
- assert( e.type() == Code );
- const char *code = e.valuestr();
+ assert( e.type() == Code || e.type() == CodeWScope );
+ const char *code = e.type() == Code ? e.valuestr() : e.codeWScopeCode();
+
if ( ! JavaJS ) {
result.append("errmsg", "db side execution is disabled");
return false;
}
-
+
jlong f = JavaJS->functionCreate(code);
if( f == 0 ) {
result.append("errmsg", "compile failed");
@@ -58,6 +59,8 @@ bool dbEval(JSObj& cmd, JSObjBuilder& result) {
}
Scope s;
+ if ( e.type() == CodeWScope )
+ s.init( e.codeWScopeScopeData() );
s.setString("$client", client->name.c_str());
Element args = cmd.findElement("args");
if( args.type() == Array ) {
@@ -314,7 +317,7 @@ bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b,
if( !ok )
anObjBuilder.append("errmsg", errmsg);
}
- else if( e.type() == Code ) {
+ else if( e.type() == Code || e.type() == CodeWScope ) {
valid = true;
ok = dbEval(jsobj, anObjBuilder);
}