如何将两个参数值传递给 couchdb 视图?
我想在 CouchDB 视图中重现此 SQL。
SELECT name,department FROM Persons where id = ? and group_id = ? ;
如何在 CouchDB 中为此 SQL 编写视图和查询视图?
I want to reproduce this SQL in CouchDB views.
SELECT name,department FROM Persons where id = ? and group_id = ? ;
How do I write a view and query view in CouchDB for this SQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编写这样的视图:
我将您的 id 更改为 person_id,因此它不能轻易与 _id 混淆
我使用数组作为视图的键,因此您可以轻松地像这样查询它:
这或多或少是这样的查询:
这是一篇关于使用视图进行过滤和排序的文章:http://barkingiguana.com/2009/01/22/filtering-and-ordering -couchdb-view-results/
在 couchdb wiki 中有一个关于视图的非常好的页面:http://wiki.apache.org/couchdb/HTTP_view_API
couchdb 指南中的这一章解释了数组键: http://guide.couchdb.org/draft/views.html
You could write a view like this one:
I changed your id to person_id so it cannot be easily confused with _id
I used an array as key for the view, so you can easily query it like this:
This would be more or less like this query:
Here is an article about filtering and ordering with views: http://barkingiguana.com/2009/01/22/filtering-and-ordering-couchdb-view-results/
There is a very good page in the couchdb wiki on views: http://wiki.apache.org/couchdb/HTTP_view_API
This chapter in the couchdb guide explains array keys: http://guide.couchdb.org/draft/views.html