CouchDB 布尔过滤
CouchDB boolean filtering
我正在尝试使用 CouchDB
filtering 但我不明白它是如何工作的
所以让我们说,就像他们的例子一样:
function(doc, req){
// we need only `mail` documents
if (doc.type != 'mail'){
return false;
}
// we're interested only in `new` ones
if (doc.status != 'new'){
return false;
}
return true; // passed!
}
我有点困惑,因为如果我只想 return
mail documents
我想我应该实现类似的东西:
if (doc.type == 'mail'){
return true;
}
最后我们有
return true //passed
但是,这是否意味着我将 return 我拥有的所有文件?
该示例不仅过滤邮件文档,还要求它们是新的。没有 "new document check" 你也可以把代码写成
function(doc, req){
// we need only `mail` documents
if (doc.type == 'mail') {
return true;
}
return false;
}
但是,原始的整个逻辑正在实现(以伪代码形式)
if (!mail document or !new document) then false
else true
我正在尝试使用 CouchDB
filtering 但我不明白它是如何工作的
所以让我们说,就像他们的例子一样:
function(doc, req){
// we need only `mail` documents
if (doc.type != 'mail'){
return false;
}
// we're interested only in `new` ones
if (doc.status != 'new'){
return false;
}
return true; // passed!
}
我有点困惑,因为如果我只想 return
mail documents
我想我应该实现类似的东西:
if (doc.type == 'mail'){
return true;
}
最后我们有
return true //passed
但是,这是否意味着我将 return 我拥有的所有文件?
该示例不仅过滤邮件文档,还要求它们是新的。没有 "new document check" 你也可以把代码写成
function(doc, req){
// we need only `mail` documents
if (doc.type == 'mail') {
return true;
}
return false;
}
但是,原始的整个逻辑正在实现(以伪代码形式)
if (!mail document or !new document) then false
else true