如何使用“任何”过滤视图比较?
我在 couchdb 中有一个数据库,其中包含 4 个文档... 这里是示例
这是文档来源:
{"_id": "...","gender": "F","hat": "BLUE"}
{"_id": "...","性别": "F","帽子": "红色"}
{"_id": "...","性别": "M","帽子“:“蓝色”}
{"_id": "...","gender": "M","hat": "RED"}
这是我的观点:
function(doc) {
emit([doc.gender,doc.hat], doc);
}
但我想通过以下情况获取数据:
- 选择性别均为“F”且任何种类的帽子(完成 | 样本)
- 选择所有具有任何类型性别并具有“红色”帽子(堆栈)
如何使第二点起作用?
如何通过“任何”比较来过滤视图?
i have a database in couchdb which contain 4 documents... here the sample
and here is the the document source:
{"_id": "...","gender": "F","hat": "BLUE"}
{"_id": "...","gender": "F","hat": "RED"}
{"_id": "...","gender": "M","hat": "BLUE"}
{"_id": "...","gender": "M","hat": "RED"}
here is my view:
function(doc) {
emit([doc.gender,doc.hat], doc);
}
but i want to fetch data with following case :
- select all with gender 'F' and any kind of hat (done | sample)
- select all with any kind of gender and have "RED' hat (stack)
how to make second point works??
how to filter view with "any" comparison ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于第二点,你需要这样的视图;
使用 ?key="RED" 进行查询。
注意:我发出 null 以节省索引空间。使用 ?include_docs=true 查询以获取文档。
For the second point, you need a view like this;
Query with ?key="RED".
Note: I emit null to save space in the index. Query with ?include_docs=true to get the docs back.