在开始日期和结束日期之间查询CouchDB文档 [英] Querying CouchDB documents between a start date and an end date

查看:1029
本文介绍了在开始日期和结束日期之间查询CouchDB文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找出如何创建一个CouchDB视图,让我查询开始日期大于A,结束日期小于B的所有文档。



这可能在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年给你所有的东西。



这些应该有帮助:




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:

这篇关于在开始日期和结束日期之间查询CouchDB文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆