From 2e7f6c199f307acd43fe4989ab99e4b542f4c509 Mon Sep 17 00:00:00 2001 From: Chun-hao Hu Date: Tue, 15 May 2012 17:16:28 +0100 Subject: [PATCH] Change replacement string --- utils.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils.js b/utils.js index e42af0705..d902138f3 100644 --- a/utils.js +++ b/utils.js @@ -24,6 +24,7 @@ exports.getSandbox = function() { ObjectID: mongodb.ObjectID, Timestamp: mongodb.Timestamp, DBRef: mongodb.DBRef, + Dbref: mongodb.DBRef, Binary: mongodb.Binary, BinData: mongodb.Binary, Code: mongodb.Code, @@ -54,15 +55,15 @@ exports.docToString = function(doc) { var replacer = function(key, value) { if (doc[key] instanceof mongodb.ObjectID) { - return '""ObjectId(rep"lace' + value + 'rep"lace)""'; + return '""ObjectId($$replace$$' + value + '$$replace$$)""'; } else if (doc[key] instanceof mongodb.Long) { - return '""Long(rep"lace' + value + 'rep"lace)""'; + return '""Long($$replace$$' + value + '$$replace$$)""'; } else if (doc[key] instanceof mongodb.Double) { - return '""Double(rep"lace' + value + 'rep"lace)""'; + return '""Double($$replace$$' + value + '$$replace$$)""'; } else if (doc[key] instanceof mongodb.Timestamp) { - return '""Timestamp(rep"lace' + value + 'rep"lace)""'; + return '""Timestamp($$replace$$' + value + '$$replace$$)""'; } else if (doc[key] instanceof Date) { - return '""ISODate(rep"lace' + value + 'rep"lace)""'; + return '""ISODate($$replace$$' + value + '$$replace$$)""'; } else { return value; } @@ -72,7 +73,7 @@ exports.docToString = function(doc) { newDoc = newDoc.replace(/"\\"\\"/gi, ""); newDoc = newDoc.replace(/\\"\\""/gi, ""); - newDoc = newDoc.replace(/rep\\"lace/gi, "\""); + newDoc = newDoc.replace(/\$\$replace\$\$/gi, "\""); return newDoc; };