summaryrefslogtreecommitdiff
path: root/shell/utils.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-10-02 17:07:07 -0400
committerEliot Horowitz <eliot@10gen.com>2009-10-02 17:07:07 -0400
commitcc2c5c491100d3c8782a1c95b6fc362db91158c5 (patch)
treedd7fa8efde833e170c387b77c82420339b0c2128 /shell/utils.js
parenteaf0c845bccc01d61b7971b8c3b507fc7a175d38 (diff)
downloadmongo-cc2c5c491100d3c8782a1c95b6fc362db91158c5.tar.gz
add new style DBRef to js SERVER-243
Diffstat (limited to 'shell/utils.js')
-rw-r--r--shell/utils.js20
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;