3
搜索我有一些文件格式如下:CouchDB的 - 如何通过阵列
{
url: 'some-unique-url',
name: 'some-name'
}
我需要做的是选择通过提供包含URL的一个阵列有一个特定的URL的文件,其我需要选择:
['some-unique-url', 'another-url']
这里就是我的观点现在看起来像:
function(doc) {
if(doc.type == 'message'){
emit([doc.url], null);
}
}
这里是我的node.js代码。我正在使用nano。
db.view('message', 'by_url', {'key': urls}, function(err, body){
res.send(body);
});
这个作品,如果我只有一个项目在数组中,但只要我添加其他项目,这里就是我得到:
{"total_rows":18,"offset":11,"rows":[]}
我也试过startkey
和endkey
也可以工作,但它行为方式与上一个相同:
db.view('message', 'by_url', {'startkey': online_users_ids, 'endkey': [online_users_ids, {}]}, function(err, body){
res.send(body);
});
是我正在尝试使用couchdb和nano做什么吗?如果不是,我可以在不丢失表现的情况下获得最接近的东西?提前致谢!