I have a collection that has a number of documents where the title contains encoded & characters (&) and I would like to convert these back.
I'm wondering if it is possible to do a string replacement on a value based on it's original value.
For example with the document below:
{
title: "this & that"
}
Is it possible to replace the & with a normal update statement? I tried something like this:
db.questions.update({title: /&/}, {title: title.replace(/&/g, "&")});
But it threw the following error: ReferenceError: title is not defined
Can it be done using an update statment? If not, is the best way just to do a find/foreach/update on each document?