CouchDB:仅查看 return 某些文档?

CouchDB: View to return only certain documents?

我已经(尝试)编写一个视图来识别具有 "otherCauseForRelease" 属性的文档,并且该属性实际上已被填充。我的查看代码是:

function (doc) {
if(doc.payload.otherCauseForRelease.length > 5);  emit(doc.payload.otherCauseForRelease);
}

但是,return 集包含属性值如“”(左双引号后跟右双引号)的文档。如何从我的结果中排除这些文档?

在这里试试这个:

函数(文档){ 如果(doc.payload.otherCauseForRelease.length > 5) 发出(doc.payload.otherCauseForRelease); }

您基本上是在 if 的末尾添加一个额外的 ;。这样做,它不会将下一个语句视为 if 的主体。

另一个带花括号的例子:

function (doc) {
 if(doc.payload.otherCauseForRelease.length > 5){
     emit(doc.payload.otherCauseForRelease);
    }
 }