diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-07-06 13:47:00 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-07-06 13:47:00 -0400 |
commit | a96c97161eaff686449560e4f3f5029d91287656 (patch) | |
tree | ea6f44abeebe009ff1476032ed000e65dcc644ba | |
parent | 7bb37b3fd2dfdd3ff3c15634236b4ca487ceda62 (diff) | |
download | mongo-a96c97161eaff686449560e4f3f5029d91287656.tar.gz |
make objectid serialize to something parseable
-rw-r--r-- | jstests/objid1.js | 3 | ||||
-rw-r--r-- | shell/utils.js | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/jstests/objid1.js b/jstests/objid1.js index f0b62ef5d0c..dea31eed0d8 100644 --- a/jstests/objid1.js +++ b/jstests/objid1.js @@ -11,3 +11,6 @@ t.save( { a : a } ) assert( t.findOne().a.isObjectId , "C" ); assert.eq( a.str , t.findOne().a.str , "D" ); +x = { a : new ObjectId() }; +eval( " y = " + tojson( x ) ); +assert.eq( x.a.str , y.a.str , "E" ); diff --git a/shell/utils.js b/shell/utils.js index 204ddec5919..ef2889fc867 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -188,7 +188,7 @@ ObjectId.prototype.toString = function(){ } ObjectId.prototype.tojson = function(){ - return "\"" + this.str + "\""; + return " ObjectId( \"" + this.str + "\") "; } ObjectId.prototype.isObjectId = true; |