My current id keys contains from 3 or 4 segments:
namespace::my_key::id
namespace::my_key::my_second_key::id
Solution 1. Use complex id's and create views by searching in id for a key
function (doc, meta) {
if(meta.id.indexOf("::my_key::") !== -1){
emit([doc.source_id], [doc.name,doc.title,doc.ui]);
}
}
Solution 2. For every document add fields like "type", "namespace" And creat views using them
function (doc, meta) {
if(doc.type=='my_key'){
emit([doc.source_id], [doc.name,doc.title,doc.ui]);
}
}
If i choose Solution 2, I have to maintain id's on my application and probably i will do as in solution 1.
Does anyone have experience in naming id's and creating views from them? what problems you had with each of these solutions. Or maybe indexOf() function is not recommended?