Created
September 1, 2016 16:38
-
-
Save joadr/ec1e4ba731988e9dc7a3d47b91789f87 to your computer and use it in GitHub Desktop.
Mongo gridfs meteor url changer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When meteor starts | |
Meteor.startup(function () { | |
// Recursive function to replace urls | |
function fixUrl (object) { | |
_.map(object, function (value, key) { | |
if (_.isArray(value)) { | |
_.map(value, function (value2, key2) { | |
value2 = fixUrl(value2) | |
}) | |
} else if (_.isObject(value)) { | |
if (value.url) { | |
value.url = value.url.replace('http://localhost:3000/', 'http://raicap.com/') // change urls part you whant to change | |
} else { | |
value = fixUrl(value) | |
} | |
} | |
}) | |
return object | |
} | |
var newDoc = fixUrl(orion.dictionary.findOne()) | |
delete newDoc._id | |
orion.dictionary.update({}, {$set: newDoc }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment