0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00

update vstudio shell files MINOR

This commit is contained in:
Eliot Horowitz 2009-07-13 16:37:36 -04:00
parent 252c621fc3
commit f1253179ce

View File

@ -87,13 +87,21 @@ const char * jsconcatcode =
"\n"
"}\n"
"\n"
"\n"
"DBCollection.prototype._validateObject = function( o ){\n"
"if ( o._ensureSpecial && o._checkModify )\n"
"throw \"can't save a DBQuery object\";\n"
"}\n"
"\n"
"DBCollection.prototype._validateForStorage = function( o ){\n"
"this._validateObject( o );\n"
"for ( var k in o ){\n"
"if ( k.indexOf( \".\" ) >= 0 )\n"
"throw \"can't have . in field names [\" + k + \"]\" ;\n"
"}\n"
"}\n"
"\n"
"\n"
"DBCollection.prototype.find = function( query , fields , limit , skip ){\n"
"return new DBQuery( this._mongo , this._db , this ,\n"
"this._fullName , this._massageObject( query ) , fields , limit , skip );\n"
@ -124,6 +132,7 @@ const char * jsconcatcode =
"DBCollection.prototype.update = function( query , obj , upsert ){\n"
"assert( query , \"need a query\" );\n"
"assert( obj , \"need an object\" );\n"
"this._validateObject( obj );\n"
"return this._mongo.update( this._fullName , query , obj , upsert ? true : false );\n"
"}\n"
"\n"
@ -506,7 +515,15 @@ const char * jsconcatcode =
"DB.prototype.shutdownServer = function() {\n"
"if( \"admin\" != db )\n"
"return \"shutdown command only works with the admin database; try 'use admin'\";\n"
"return this._dbCommand(\"shutdown\");\n"
"\n"
"try {\n"
"this._dbCommand(\"shutdown\");\n"
"throw \"shutdownServer failed\";\n"
"}\n"
"catch ( e ){\n"
"assert( tojson( e ).indexOf( \"error doing query: failed\" ) >= 0 , \"unexpected error: \" + tojson( e ) );\n"
"print( \"server should be down...\" );\n"
"}\n"
"}\n"
"\n"
"/**\n"
@ -1418,6 +1435,13 @@ const char * jsconcatcode =
"func( this.next() );\n"
"}\n"
"\n"
"DBQuery.prototype.map = function( func ){\n"
"var a = [];\n"
"while ( this.hasNext() )\n"
"a.push( func( this.next() ) );\n"
"return a;\n"
"}\n"
"\n"
"DBQuery.prototype.arrayAccess = function( idx ){\n"
"return this.toArray()[idx];\n"
"}\n"
@ -1437,8 +1461,13 @@ const char * jsconcatcode =
"print( s );\n"
"n++;\n"
"}\n"
"if ( this.hasNext() )\n"
"if ( this.hasNext() ){\n"
"print( \"has more\" );\n"
"___it___ = this;\n"
"}\n"
"else {\n"
"___it___ = null;\n"
"}\n"
"}\n"
"catch ( e ){\n"
"print( e );\n"
@ -2010,7 +2039,7 @@ const char * jsconcatcode =
"}\n"
"\n"
"ObjectId.prototype.tojson = function(){\n"
"return \"\\\"\" + this.str + \"\\\"\";\n"
"return \" ObjectId( \\\"\" + this.str + \"\\\") \";\n"
"}\n"
"\n"
"ObjectId.prototype.isObjectId = true;\n"
@ -2035,13 +2064,25 @@ const char * jsconcatcode =
"}\n"
"\n"
"tojson = function( x ){\n"
"if ( x == null || x == undefined )\n"
"if ( x == null )\n"
"return \"null\";\n"
"\n"
"if ( x == undefined )\n"
"return \"\";\n"
"\n"
"switch ( typeof x ){\n"
"\n"
"case \"string\":\n"
"return \"\\\"\" + x + \"\\\"\";\n"
"case \"string\": {\n"
"var s = \"\\\"\";\n"
"for ( var i=0; i<x.length; i++ ){\n"
"if ( x[i] == '\"' ){\n"
"s += \"\\\\\\\"\";\n"
"}\n"
"else\n"
"s += x[i];\n"
"}\n"
"return s + \"\\\"\";\n"
"}\n"
"\n"
"case \"number\":\n"
"case \"boolean\":\n"
@ -2129,32 +2170,18 @@ const char * jsconcatcode =
"print( tojson( x ) );\n"
"}\n"
"\n"
"execShellLine = function(){\n"
"var l = __line__.trim();\n"
"\n"
"var cmd = l.substring( 0 , ( l.indexOf( \" \" ) || l.length ) );\n"
"if ( cmd.length == 0 )\n"
"cmd = l;\n"
"\n"
"if ( shellHelper[ cmd ] ){\n"
"shellHelper( cmd , l.substring( cmd.length + 1 ).trim() );\n"
"return;\n"
"}\n"
"\n"
"var res = eval( l );\n"
"if ( typeof( res ) != \"undefined\" ){\n"
"shellPrintHelper( res );\n"
"}\n"
"}\n"
"\n"
"shellHelper = function( command , rest ){\n"
"shellHelper = function( command , rest , shouldPrint ){\n"
"command = command.trim();\n"
"var args = rest.trim().replace(/;$/,\"\").split( \"\\s+\" );\n"
"\n"
"if ( ! shellHelper[command] )\n"
"throw \"no command [\" + command + \"]\";\n"
"\n"
"return shellHelper[command].apply( null , args );\n"
"var res = shellHelper[command].apply( null , args );\n"
"if ( shouldPrint ){\n"
"shellPrintHelper( res );\n"
"}\n"
"return res;\n"
"}\n"
"\n"
"help = shellHelper.help = function(){\n"
@ -2176,6 +2203,14 @@ const char * jsconcatcode =
"print( \"switched to db \" + db.getName() );\n"
"}\n"
"\n"
"shellHelper.it = function(){\n"
"if ( typeof( ___it___ ) == \"undefined\" || ___it___ == null ){\n"
"print( \"no cursor\" );\n"
"return;\n"
"}\n"
"shellPrintHelper( ___it___ );\n"
"}\n"
"\n"
"shellHelper.show = function( what ){\n"
"assert( typeof what == \"string\" );\n"
"\n"