summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-08-21 01:36:41 -0400
committerEliot Horowitz <eliot@10gen.com>2009-08-21 01:36:41 -0400
commite1928bfda516298dc4dfa1b2782458422cbc98c9 (patch)
treed35377fcdbd20f4da44cad053b9871173dfc47d7
parent1bc91420b391cedbb6c7eb417735e14d202434a1 (diff)
downloadmongo-e1928bfda516298dc4dfa1b2782458422cbc98c9.tar.gz
some safety for other JS impls MINOR
-rw-r--r--shell/utils.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/shell/utils.js b/shell/utils.js
index 37f2923a24d..568ebc6a44d 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -198,23 +198,33 @@ ObjectId.prototype.tojson = function(){
ObjectId.prototype.isObjectId = true;
-DBRef.prototype.fetch = function(){
- assert( this.ns , "need a ns" );
- assert( this.id , "need an id" );
+if ( typeof( DBRef ) != "undefined" ){
+ DBRef.prototype.fetch = function(){
+ assert( this.ns , "need a ns" );
+ assert( this.id , "need an id" );
+
+ return db[ this.ns ].findOne( { _id : this.id } );
+ }
+
+ DBRef.prototype.tojson = function(){
+ return "{ 'ns' : \"" + this.ns + "\" , 'id' : \"" + this.id + "\" } ";
+ }
- return db[ this.ns ].findOne( { _id : this.id } );
+ DBRef.prototype.toString = function(){
+ return "DBRef " + this.ns + ":" + this.id;
+ }
}
-
-DBRef.prototype.tojson = function(){
- return "{ 'ns' : \"" + this.ns + "\" , 'id' : \"" + this.id + "\" } ";
+else {
+ print( "warning: no DBRef" );
}
-DBRef.prototype.toString = function(){
- return "DBRef " + this.ns + ":" + this.id;
+if ( typeof( BinData ) != "undefined" ){
+ BinData.prototype.tojson = function(){
+ return "BinData type: " + this.type + " len: " + this.len;
+ }
}
-
-BinData.prototype.tojson = function(){
- return "BinData type: " + this.type + " len: " + this.len;
+else {
+ print( "warning: no BinData" );
}
tojson = function( x ){