Renaming a large number of CouchDb

For example, I have entries with tag names, and I decided to rename one of the tags. Mass update when I need to know that the revision is not suitable. Better if it can be integrated somehow.

+3
source share
1 answer

Check out Costco , which provides a simple interface that allows you to write a small function that applies to all of your documents to change them.

You should write a simple function, for example:

function (doc) {
  // ignore documents without tags
  if (!doc.tags) return doc;

  for (var i = 0, len = doc.tags.length; i < len; i += 1) {
    // convert tag misspelled "couch-db" to real name "CouchDB"
    if (doc.tags[i] === "couch-db") doc.tags[i] = "CouchDB";
  }
  return doc;
}
+1
source

Source: https://habr.com/ru/post/1766532/


All Articles