I have several collections in mongodb and I would like to do a "search / replace" for all collections and for each field that is string "http:" replace with "https:"
Example:
var object = {
"_id" : ObjectId("58e7c7a5b03d4641f2aad7bb"),
"t1" : "Exemplo 1 http:// ocorrencia",
"t2" : "Exemplo 12 silva service souza encontrado na url http://192.22.11.102:8080",
"image" : [
{
"image_id" : ObjectId("58e2e041a4c8023a35a4260e"),
"blog" : "http://10.11.12.23"
},
{
"blog" : "http://10.11.12.23"
}
],
"tr" : {
"ts" : "Maria Santanta",
"message" : "http://message"
},
"date" : "2016-02-25T20:39:26.084Z"
}
I was able to replace all occurrences using:
var string = JSON.stringify(object)
string = string.replace(/http:/g,"https:")
The problem is to convert back to json object because it does not recognize ObjectId, ISODate among others.
I tried to use
JSON.parse(string)
unsuccessful