0

"dependencies": { "mongoose": "^5.2.8" }

"coverImage" : { "url" : "http://foo.com/media/hgfr2um5oqibs8lbjbv7.jpg", "size" : 0, "filename" : "hgfr2um5oqibs8lbjbv7.jpg" }

Hi everyone. I'm trying to update url to https://bar.com.s/media/hgfr2um5oqibs8lbjbv7.jpg without querying doc and updating. Is there anyway to do it ?

S.Polat
  • 71
  • 8
  • See this https://stackoverflow.com/a/6437345/6121568 I think you could find that string and replace it using OS code. – Emeeus Aug 18 '18 at 18:55

1 Answers1

0

Hey @Emeeus thanks for the reply but I resolved my issue by another way.Here is my solution:

db.media.find({mediaContainer:"ContainerS3"}).forEach(function(e,i) {
    e.url=e.url.replace("//a.n.com","//b.n.com");
    db.media.save(e);
});

By writing this query to robomongo app. (Referenced from: How to replace substring in mongodb document)

S.Polat
  • 71
  • 8