diff --git a/db/jsobj.h b/db/jsobj.h index d59fb4e5d72..a634e680b2e 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -576,6 +576,13 @@ namespace mongo { return getField(field); } + BSONElement operator[] (int field) const { + stringstream ss; + ss << field; + string s = ss.str(); + return getField(s.c_str()); + } + /** @return true if field exists */ bool hasField( const char * name )const { return ! getField( name ).eoo(); diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp index 08d98e15bd8..2ebbe88e4cb 100644 --- a/scripting/engine_spidermonkey.cpp +++ b/scripting/engine_spidermonkey.cpp @@ -288,7 +288,7 @@ namespace mongo { assert( array ); for ( int i=0; i