diff options
Diffstat (limited to 'shell/utils.js')
-rw-r--r-- | shell/utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/shell/utils.js b/shell/utils.js index 3071474e7b9..9e100be144e 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -257,6 +257,26 @@ else { print( "warning: no DBPointer" ); } +if ( typeof( DBRef ) != "undefined" ){ + DBRef.prototype.fetch = function(){ + assert( this.$ref , "need a ns" ); + assert( this.$id , "need an id" ); + + return db[ this.$ref ].findOne( { _id : this.$id } ); + } + + DBRef.prototype.tojson = function(){ + return "{ '$ref' : \"" + this.ns + "\" , '$id' : \"" + this.id + "\" } "; + } + + DBRef.prototype.toString = function(){ + return this.tojson(); + } +} +else { + print( "warning: no DBRef" ); +} + if ( typeof( BinData ) != "undefined" ){ BinData.prototype.tojson = function(){ return "BinData type: " + this.type + " len: " + this.len; |