在开始日期和结束日期之间查询CouchDB文档 [英] Querying CouchDB documents between a start date and an end date
问题描述
这可能在CouchDB或其他noSQL文件存储中吗?我应该废弃它并返回到SQL?
我只是想做这个SQL的等价物:
SELECT * WHERE [start timestamp]> = doc.start AND [end timestamp]< doc.end;
只需创建一个这样的地图:
function(doc){emit(doc.timestamp,1)}
然后查询视图:
?descending = true& limit = 10& include_docs = true //获取最新10个文件
视图将被排序最旧到最新,因此 descending = true
反转该订单。
如果您想要一个特定的范围。
?startkey =1970-01-01T00:00:00Z& endkey =1971-01-01T00:00:00Z
将在1970年给你所有的东西。
这些应该有帮助:
- http://wiki.apache.org/couchdb/ Introduction_to_CouchDB_views
- http://wiki.ap ache.org/couchdb/HttpViewApi
- http: //wiki.apache.org/couchdb/View_collation
I've been trying to figure out how to create a CouchDB view that will let me query all the documents that have a start date greater than A and an end date less than B.
Is this possible in CouchDB or another noSQL document store? Should I scrap it and go back to SQL?
I'm simply trying to do the SQL equivalent of:
SELECT * WHERE [start timestamp] >= doc.start AND [end timestamp] < doc.end;
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
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"
would get you everything in 1970.
These should help:
- http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views
- http://wiki.apache.org/couchdb/HttpViewApi
- http://wiki.apache.org/couchdb/View_collation
这篇关于在开始日期和结束日期之间查询CouchDB文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!