且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在开始日期和结束日期之间查询 CouchDB 文档

更新时间:2023-01-29 20:22:07

只需像这样创建一个地图:

Just create a map like this:

function (doc) {emit(doc.timestamp, 1)}

然后使用以下命令查询视图:

then query the view with:

?descending=true&limit=10&include_docs=true // Get the latest 10 documents

视图将按从旧到新排序,因此 descending=true 会颠倒该顺序.

The view will be sorted oldest to latest so descending=true reverses that order.

如果你想要一个特定的范围.

If you want a specific range.

?startkey="1970-01-01T00:00:00Z"&endkey="1971-01-01T00:00:00Z"

会在 1970 年为您提供一切.

would get you everything in 1970.

这些应该会有所帮助: