I have the following query, to find
tags in a name field and replace them with an empty space - to get rid of them.
Name strings can have 1 to many
tags e.g.
AA aa
AA aa
AA aa
AA aa
AA AA aaaaaaaa
... like that.
db.tests.find({'name':/.* .*/}).forEach(function(test){
test.name = test.name.replace(" ","");
db.tests.save(test);
});
db.tests.find({'name':/.* .*/}).forEach(function(test){
test.name = test.name.replace(" ","");
db.tests.save(test);
});
db.tests.find({'name':/.* .*/}).forEach(function(test){
test.name = test.name.replace(" ","");
db.tests.save(test);
});
Other than repeating the same query pattern, is there a better solution to handle this scenario, in terms of less duplication and higher performance?