Skip to content

Commit

Permalink
Change replacement string
Browse files Browse the repository at this point in the history
  • Loading branch information
andzdroid committed May 15, 2012
1 parent 93a80c1 commit 2e7f6c1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions utils.js
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
};

0 comments on commit 2e7f6c1

Please sign in to comment.