Temporary submission of couchdb doc_id regular expression documents

I have a couchdb database containing various types of documents. Unfortunately, some of these documents were created without the type field, so I cannot easily distinguish them. I want to add this type field. Fortunately, doc_id also has this information, and I want to use it to perform the update.

I would like to create a temporary representation of documents whose doc_id matches a particular regular expression, say:

 ^user_ 

Is there any way to define such a display function?

+1
source share
1 answer

It works as expected:

 function(doc) { if (doc._id.match(/^user_.*$/)) { emit(null, doc); } } 

Have you even tried anything?

+1
source

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


All Articles