diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-10-02 17:07:07 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-10-02 17:07:07 -0400 |
commit | cc2c5c491100d3c8782a1c95b6fc362db91158c5 (patch) | |
tree | dd7fa8efde833e170c387b77c82420339b0c2128 /shell/utils.js | |
parent | eaf0c845bccc01d61b7971b8c3b507fc7a175d38 (diff) | |
download | mongo-cc2c5c491100d3c8782a1c95b6fc362db91158c5.tar.gz |
add new style DBRef to js SERVER-243
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; |