长沙发视图使用其他视图? [英] couchdb view using another view?

查看:66
本文介绍了长沙发视图使用其他视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对沙发床中的视图有疑问 目前,我有很多视图(例如view_A,view_B .... view_Z),每个视图都包含相同范围的键,但具有不同的值.即:

I have got questions about views in couchdb At the moment, I have a number of views (e.g. view_A, view_B.... view_Z), for each view they contains same range of keys but with different values. ie:

view_A = {"key":"key_1", "value":10}, {"key":"key_2", "value":100}
view_B = {"key":"key_1", "value":5}, {"key":"key_2", "value":2}
view_C = {"key":"key_1", "value":1}, {"key":"key_2", "value":2}

我希望有一个视图来表示view_A中的值除以view_B中的值=>

I am expecting to have a view to represent values in view_A divided by values in view_B =>

view_A_over_B = {"key":"key_1", "value":2}, {"key":"key_2", "value":50}

表示view_C中的值的视图乘以view_B中的值=>

A view to represent values in view_C times values in view_B =>

view_C_times_B = {"key":"key_1", "value":5}, {"key":"key_2", "value":4}

是否可以有一个map/reduce函数来调用视图并像上面提到的那样进行计算?

Would this be possible to have a map/reduce function which is calling the views and do the calculation as mentioned like above?

推荐答案

CouchDB中的视图只能访问正在处理的当前文档,而不能访问其他文档或其他视图中的数据.因此,不幸的是,无法使用CouchDB中的视图来构建所需的功能.

Views in CouchDB can only access the current document being processed and cannot access other documents, or data from other views. So, unfortunately, it is not possible using views in CouchDB to build the functionality you want.

由于不清楚如何构建视图,可能可以使用列表函数代替视图来构建所需的结果.列表函数功能更强大,但您负责输出结果(如HTML,Json等).

As it's not clear how you're building the views, it may be possible to use List functions instead of views to build the results you need. List functions are more capable, but you're then responsible for outputting the results (as HTML, Json, etc.).

这篇关于长沙发视图使用其他视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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