具有多个键格式的CouchDB查询视图 [英] CouchDB Query View with Multiple Keys Formatting

查看:91
本文介绍了具有多个键格式的CouchDB查询视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用多个键时,在获取沙发床视图以返回正确的文档时遇到问题.

I'm having a problem getting a couchdb view to return the proper documents when using multiple keys.

这很好,可以返回匹配的文档:

GET http://example.com:5984/myDb/_design/myFilters/_view/getItemByForeignKeyId?key = abc123

此返回值返回视图中所有匹配或不匹配的文档:

GET http://example.com:5984/myDb/_design/myFilters/_view/getItemByForeignKeyId?keys=%5B%22abc123%22%5D

我通常很擅长寻找答案.但是,CouchDB文档对于使用多个键的格式非常清楚.我见过一些使用?keys = [123,123]的人,也见过?keys ="abc","abc".

I'm usually very good at hunting down my answers. But, CouchDB documentation is very clear on the format for using multiple keys. I've seen some use the ?keys=[123,123] and i've also seen ?keys="abc","abc".

如果任何人都可以使用 GET 方法对CouchDB的正确"格式和多个关键查询的编码提供任何说明,我将非常感激.

If anyone can offer any clarification on the 'proper' format and encoding of multiple key queries for CouchDB using a GET method, I would be extremely appreciative.

推荐答案

要从视图中获取多个键,您需要执行发布请求,然后在请求正文中提交这些键.您的HTTP请求将如下所示:

To get multiple keys from a view, you need to do a post request and submit the keys in the request body. Your HTTP request will look like this:

POST /myDb/_design/myFilters/_view/getItemByForeignKeyId
Content-Type: application/json

{
   "keys" : [
      "abc",
      "123"
   ]
}

这篇关于具有多个键格式的CouchDB查询视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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