我正在学习couchdb,所以我有一个非常基本的问题。假设我有一个名为email
where 文档的沙发数据库:
{
"_id": "fe7759fdf36t",
"status": "sent",
"sent_at": 1357151443,
}
{
"_id": "ewrwe4a38d2353",
"status": "failed",
"sent_at": 2347151421,
}
{
"_id": "f4559fjffd2353",
"status": "sent",
"sent_at": 11715154,
}
我想创建两个视图
1) 检索所有文档 where status = sent
2) 检索所有文档 where status = failed and sent_at > 11715157
3) 检索所有按sent_at
降序/升序排序的文档status = sent
对于(1),我写道,
{
"_id": "_design/sentdoc",
"_rev": "2-dd88de7196c06eed41d2d83a958f0388",
"views": {
"query": {
"map": "function(doc) { if(doc.status == 'sent') {emit(doc_id, doc);} }"
}
}
}
我想我在那里做错了什么,所以它不起作用。谁能建议如何编写所有这三个视图?