假设我有以下文件
Document 1
{
companyId: "1",
salesDate: "1425254400000" //this is UTC time as a long
}
Document 2
{
companyId: "1",
salesDate: "1425340800000" //this is UTC time as a long
}
Document 3
{
companyId: "2",
salesDate: "1425254400000" //this is UTC time as a long
}
我目前将我的视图设置为
function(doc, meta) { emit([doc.salesDate, doc.companyId], doc); }
使用时拉回所有 3 个文档
?startkey=[1425254400000,"1"]&endkey=[1425340800000,"1"]
我不确定如何让它仅按公司 ID 拉回该日期范围内的销售额。
sql 版本将是 SELECT * FROM sales WHERE companyId = :companyId AND salesDate BETWEEN :rangeStart AND :rangeEnd
编辑:我正在使用其余的 API。