Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ibm cloud 使用API Connect/StrongLoop中的环回使用Cloudant连接器进行独特查询_Ibm Cloud_Strongloop_Cloudant_Loopback_Apiconnect - Fatal编程技术网

Ibm cloud 使用API Connect/StrongLoop中的环回使用Cloudant连接器进行独特查询

Ibm cloud 使用API Connect/StrongLoop中的环回使用Cloudant连接器进行独特查询,ibm-cloud,strongloop,cloudant,loopback,apiconnect,Ibm Cloud,Strongloop,Cloudant,Loopback,Apiconnect,我试图使用带有Cloudant连接器的环回为查询获取不同的值,但在文档中没有找到任何与此相关的内容 e、 g.我需要一个查询来转此: [ { rating: "★★★★★" }, { rating: "★★★★★" }, { rating: "★★★★★" }, { rating: "★★★★★" }, { rating: "★★★☆☆" }, { rating: "★★★☆☆" } ] 为此: [ { rating: "★★★★★" }, { rating: "★★★☆☆" } ] 我正在

我试图使用带有Cloudant连接器的环回为查询获取不同的值,但在文档中没有找到任何与此相关的内容

e、 g.我需要一个查询来转此:

[
{
rating: "★★★★★"
},
{
rating: "★★★★★"
},
{
rating: "★★★★★"
},
{
rating: "★★★★★"
},
{
rating: "★★★☆☆"
},
{
rating: "★★★☆☆"
}
]
为此:

[
{
rating: "★★★★★"
},
{
rating: "★★★☆☆"
}
]
我正在使用RESTAPI查询我的产品模型(上面是一个过滤视图,只显示评级字段)。如果有某种类型的过滤器,我可以在不修改文档中遗漏的服务器的情况下使用,那将是最好的选择

是否有任何方法可以添加一个不同的字段,如:

/Products?filter[fields][rating]=true?distinct=true
或者我该如何着手解决这个问题

另外,我还看到了另一个关于添加一个远程方法来解决这个问题的答案(类似于mySQL):

如果可以,我将如何使用Cloudant NoSQL DB连接器实现它


谢谢

如果您的文档如下所示:

{
  "name": "Star Wars",
  "year": 1978,
  "rating": "*****"
 }
您可以创建MapReduce视图,该视图以
doc.rating
作为键,并使用内置的
\u count
reducer:

 function(doc) {
   emit(doc.rating,null);
 }

当您使用
group=true
查询此视图时,
rating
的不同值将显示其在数据集中出现的计数。

我仍然不完全清楚这一点。看起来这个实现使用的是couchdb,而不是带有cloudant连接器的环回。我将在哪里创建这个新视图——在远程方法所在的模型中?
 function(doc) {
   emit(doc.rating,null);
 }