我试图从.Net MVC应用程序连接到Cloudant(沙发式数据库).我遵循使用HttpClient使用Web API的准则,如下所示:http: //www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-一个网客户端
到目前为止,我有两种方法 - 一种是获取文档,另一种是创建文档 - 两者都有错误.Get方法返回Unauthorized,Post方法返回MethodNotAllowed.
客户端创建如下:
private HttpClient CreateLdstnCouchClient()
{
// TODO: Consider using WebRequestHandler to set properties
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(_couchUrl);
// Accept JSON
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
return client;
}
Run Code Online (Sandbox Code Playgroud)
Get方法是:
public override string GetDocumentJson(string id)
{
string url = "/" + id;
HttpResponseMessage response = new HttpResponseMessage();
string strContent = "";
using (var client = CreateLdstnCouchClient())
{
response = client.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
strContent = response.Content.ReadAsStringAsync().Result;
} …Run Code Online (Sandbox Code Playgroud) Cloudant通过向/ _api/v2/api_keys发出POST来提供用于创建API密钥的API
https://docs.cloudant.com/authorization.html#creating-api-keys
但是,我没有看到任何文档说明可以删除API密钥,因此我的假设是,您只需从所有数据库的授权列表中删除密钥并停止使用它.
这是正确的方法吗?
将null或空Json传递给选择器似乎不起作用.我试图获取数据库中的所有数据.尝试:
db.list({}, function (err, data) {
if (err) {
return console.log("Error:",err.message);
}
console.log(data);
});
db.find(null, function (err, data) {
if (err) {
return console.log("Error:",err.message);
}
console.log(data);
});
db.bulk({docs:[]}, function (err, data) {
if (err) {
return console.log("Error:",err.message);
}
console.log(data);
});
Run Code Online (Sandbox Code Playgroud) 有没有人遇到过这个错误?我已经在互联网上搜索了响应,甚至写信给IBM Cloudant支持但没有.昨天它工作正常,但现在它没有用.我正在使用Zend Framework 1.12和Zend_Http_Client_Adapter_Curl()函数发送POST到Cloudant数据库.我有一个对象:
对象的一部分
$obj =
{"articles":[
{
"_id":"1100_20144071226",
"id":"1100_20144071226",
"title":"BLA BL BADASDSDDAS A BLA Native Advertising Shakes Up Agency And Brand Ecosystem",
"img":"http:\/\/s3.amazonaws.com\/static.mediapost.com\/publications\/images\/mp-logo-fb.jpg",
"titleOrg":null,
"description":"Brands such as <i class=\"highlight\">Pepsi<\/i>, Logitech,SONY, FOX, CBS, TiVo, Timberland, US Gov\'t and many more find complete, seamless satisfacting with HITVIEWS\' approach."
},
etc etc ...
]
Run Code Online (Sandbox Code Playgroud)
所以我想通过函数将其发送到curl:
$curl = new Zend_Http_Client_Adapter_Curl();
$client = new Zend_Http_Client( $this->uri."/".$db );
$client->setAdapter( $curl );
$client->setMethod( Zend_Http_Client::POST );
$client->setParameterPost("_id", $obj['id']);
$client->setParameterPost($obj);
$client->setHeaders('Content-type' ,'application/json');
return …Run Code Online (Sandbox Code Playgroud) Cloudant返回错误消息:
{"error":"invalid_key","reason":"此请求的密钥使用索引无效."}
每当我尝试使用组合运算符"$或"查询索引时.
我的文档的样本是:
{
"_id": "28f240f1bcc2fbd9e1e5174af6905349",
"_rev": "1-fb9a9150acbecd105f1616aff88c26a8",
"type": "Feature",
"properties": {
"PageName": "A8",
"PageNumber": 1,
"Lat": 43.051523,
"Long": -71.498852
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-71.49978935969642,
43.0508382914137
],
[
-71.49978564033566,
43.052210148524
],
[
-71.49791499857444,
43.05220740550381
],
[
-71.49791875962663,
43.05083554852429
],
[
-71.49978935969642,
43.0508382914137
]
]
]
}
}
Run Code Online (Sandbox Code Playgroud)
我创建的索引是对于字段"properties.PageName",当我只查询一个文档时它工作正常,但是当我尝试多个文档时,我会收到开头引用的错误响应.
如果它有帮助,这里是电话:POST https://xyz.cloudant.com/db/_find
请求机构:
{
"selector": {
"$or": [
{ "properties.PageName": "A8" },
{ "properties.PageName": "M30" },
{ "properties.PageName": "AH30" }
]
},
"use-index": "pagename-index"
}
Run Code Online (Sandbox Code Playgroud) 我有一个多维数组,我想用CouchDB索引(确实使用Cloudant)。我有一些用户,其中包含他们所属的团队的列表。我想搜索找到该团队的每个成员。因此,请获取具有ID为79d25d41d991890350af672e0b76faed的团队对象的所有User对象。我试图在“ Teams.id”上创建一个json索引,但是它不起作用,因为它不是直线数组,而是多维数组。
用户
{
"_id": "683be6c086381d3edc8905dc9e948da8",
"_rev": "238-963e54ab838935f82f54e834f501dd99",
"type": "Feature",
"Kind": "Profile",
"Email": "gc@gmail.com",
"FirstName": "George",
"LastName": "Castanza",
"Teams": [
{
"id": "79d25d41d991890350af672e0b76faed",
"name": "First Team",
"level": "123"
},
{
"id": "e500c1bf691b9cfc99f05634da80b6d1",
"name": "Second Team Name",
"level": ""
},
{
"id": "4645e8a4958421f7d843d9b34c4cd9fe",
"name": "Third Team Name",
"level": "123"
}
],
"LastTeam": "79d25d41d991890350af672e0b76faed"
}
Run Code Online (Sandbox Code Playgroud) 有人可以在MobileFirst平台上解释JSONStore和CloudantSync(CDTStore)之间的主要区别(以及作为奖励PouchDB)吗?
我很难决定哪一个会更好用.
我看到这里的文档指出,如果您需要FIPS 140-2合规性,需要同步或正在构建混合应用程序,JSONStore会更好.但是,看起来你可以用CDTStore完成所有这三个.另外,我在一些教程中看到了PouchDB.我试图理解看起来像做同样事情的不同方法之间的关键差异.任何见解将不胜感激.
是否可以使用Cloudant Query/CouchDB 2.0 Find设置$ regex标志?
具体来说,我想要一个不区分大小写的搜索,全局也很有用.
在JavaScript中我会这样做:
db.find({
selector: {
_id: {$gt: null},
series: {$regex: /mario/i}
}
});
Run Code Online (Sandbox Code Playgroud)
但我不知道如何将其编码为Erlang字符串.
到目前为止,我唯一理解的是Cloudant提供云支持并在后端使用CouchDB.
标题实际上包含完整的问题。
在CouchDB(尤其是Cloudant)中,您使用JavaScript编写带有视图的设计文档。那里支持的ECMAScript版本是什么?
我找不到相关的文档。