There is a collection of documents with a field say name . It is necessary in each document to remove from the name 3 characters at the beginning.
- The essence of the question is not clear: do you need to delete the first three characters in the text line? Or what? - Alexey Matveev
|
1 answer
If I understand correctly, do you want to go through all the documents in the collection and change the field value for each? Then you can do this:
db.getCollection('collection').find({ %условие поиска% }).forEach(function(e){ e.name= e.name.slice(3, e.name.length); //Берем строку без 3 первых символов db.getCollection('collection').save(e); //Сохраняем }) Do not forget to get drunk;)
|