我是CouchDB/Cloudant和CDN(CloudFront)的新手.
我即将使用CouchDB构建一个应用程序作为数据库.
此Web应用程序将处理大量文件.
我知道CouchDB可以将文件作为附件存储在数据库中.但后来我听说利用CDN来存储和分发全世界的文件.
我的问题:
我有一个在 IBM Bluemix 中运行的 Java 应用程序,它使用 Cloudant (couchdb) 数据库作为服务。我在该数据库中有一个无法删除的文档,因为 Cloudant 在我尝试时返回 409 冲突错误。但是,当我查询冲突时,它没有报告任何内容:
$ curl 'https://<user>-bluemix:<pass>@<host>-bluemix.cloudant.com/<dbname>/e4eca7af-cb27-4b1e-b738-31abcf880680?conflicts=true'
{
"_id": "e4eca7af-cb27-4b1e-b738-31abcf880680",
"_rev": "13887-a24ecaf2f6e628903e294b11e73d8ca8",
...[other stuff but no _conflicts section]
}
Run Code Online (Sandbox Code Playgroud)
当我尝试删除它时:
$ curl -i -X DELETE 'https://<user>-bluemix:<pass>@<host>-bluemix.cloudant.com/<dbname>/e4eca7af-cb27-4b1e-b738-31abcf880680?_rev=13887-a24ecaf2f6e628903e294b11e73d8ca8'
HTTP/1.1 409 Conflict
X-Couch-Request-ID: 02286a98ac
Server: CouchDB/1.0.2 (Erlang OTP/R14B)
Date: Wed, 15 Apr 2015 12:35:00 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 58
Cache-Control: must-revalidate
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff;
{"error":"conflict","reason":"Document update conflict."}
Run Code Online (Sandbox Code Playgroud)
这是一个已被删除和重新创建多次的文档(这就是 _rev 计数变得如此之高的原因)。通常它工作正常,但它时不时地进入这种冲突状态。我发现我可以通过 Cloudant Web 界面删除它,但似乎不能通过 REST 界面删除它。但是一旦我删除它,它就可以正常工作一段时间,然后问题又回来了。
那么为什么当我尝试删除时它会说存在冲突,但它不会告诉我与 'conflicts=true' 参数的冲突是什么?我也试过 '_deleted_conflicts=true' 这也没有显示任何内容。
它是如何进入这种状态的,我如何才能防止它在未来发生?
现在,CloudantSync(CDTDataStore)可以使用CloudantSyncEncryption加密localstore. MobileFirst Platform Foundation的IMFData增加了安全性并依赖于CloudantSync.
有没有IMFData和CloudantSync加密的组合方式?
IMFData创建如下的本地数据存储.
IMFDataManager *manager = [IMFDataManager sharedInstance];
NSString *name = @"automobiledb";
NSError *error = nil;
//Create local store
CDTStore *store = [manager localStore:name error:&error];
Run Code Online (Sandbox Code Playgroud)
CloudantSync创建加密的本地数据存储,如下所示.
// To create an encrypted datastore, create your datastore using an object
// implementing the CDTKeyProvider protocol
CDTDatastoreManager *manager =[[CDTDatastoreManager alloc] initWithDirectory:path error:&error];
CDTEncryptionKeychainProvider *provider = [CDTEncryptionKeychainProvider
providerWithPassword:@"blahblah"
forIdentifier:@"default"];
CDTDatastore *encrypted = [manager datastoreNamed:@"encrypted_datastore"
withEncryptionKeyProvider:provider
error:&error];
Run Code Online (Sandbox Code Playgroud) 我正在使用CloudantDB在Node上创建一个简单的应用程序,但我找不到如何通过电子邮件搜索用户进行简单的查找.
在MongoDB上我只做:db.find({email:"email@email.com"});
我认为可以在Cloudant上完成同样的工作,但我在Cloudant文档(https://docs.cloudant.com/document.html)或github示例(https://github.com/david-araujo)上找不到任何相关信息./ nodejs-cloudant).
关注我的代码:
Cloudant = require('cloudant')
const DB_CONN = {
account : 'user.cloudant.com',
password: 'clodantpass'
};
let cloudant = Cloudant(DB_CONN);
let db = cloudant.use('teste');
// SIMPLE INSERT
db.insert( {name : 'test', email : 'email@email.com'}, (err, data) => {
console.log(data);
} );
// SIMPLE FIND
???
Run Code Online (Sandbox Code Playgroud) 假设我的一些文档具有以下结构:
{
"something":{
"a":"b"
},
"some_other_thing":{
"c":"d"
},
"what_i_want":{
"is_down_here":[
{
"some":{
"not_needed":"object"
},
"another":{
"also_not_needed":"object"
},
"i_look_for":"this_tag",
"tag_properties":{
"this":"that"
}
},
{
"but_not":{
"down":"here"
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
是否有可以成功选择"i_look_for"具有该值的Mango JSON选择器"this_tag"?它在一个数组内(我知道它在数组中的位置).我也有兴趣过滤结果,所以我只得到 "tag_properties"结果.
我尝试了很多东西,包括$ elemMatch,但一切都回归"无效的json".
这甚至是芒果的用例还是应该坚持观点?
根据此https://docs.cloudant.com/document.html#bulk-operations 我试图将多个文档插入我的 cloudant 数据库,但出现错误:
{
"error": {
"statusCode": 400,
"name": "Error",
"request": {
"method": "POST",
"headers": {
"content-type": "application/json",
"accept": "application/json"
},
"uri": "https://XXXXXX:XXXXXX@8f7fc7f0-766b-4429-b060-4ef1c01f7665-bluemix.cloudant.com/ttt/_bulk_docs",
"body": "[{\"name\":\"Nicholas\",\"_id\":\"96f898f0-f6ff-4a9b-aac4-503992f31b01\",\"_attachments\":{},\"age\":45,\"gender\":\"male\"},{\"name\":\"Taylor\",\"_id\":\"5a049246-179f-42ad-87ac-8f080426c17c\",\"_attachments\":{},\"age\":50,\"gender\":\"male\"},{\"name\":\"Owen\",\"_id\":\"d1f61e66-7708-4da6-aa05-7cbc33b44b7e\",\"_attachments\":{},\"age\":51,\"gender\":\"male\"}]"
},
"description": "couch returned 400",
"scope": "couch",
"reason": "Request body must be a JSON object",
"error": "bad_request",
"stack": "Error: Request body must be a JSON object\n at Request._callback (/nodejsAction/node_modules/cloudant-nano/lib/nano.js:247:15)\n at Request.self.callback (/nodejsAction/node_modules/request/request.js:186:22)\n at emitTwo (events.js:106:13)\n at Request.emit (events.js:191:7)\n at Request.<anonymous> (/nodejsAction/node_modules/request/request.js:1081:10)\n at emitOne (events.js:96:13)\n at Request.emit (events.js:188:7)\n at IncomingMessage.<anonymous> (/nodejsAction/node_modules/request/request.js:1001:12)\n at IncomingMessage.g (events.js:291:16)", …Run Code Online (Sandbox Code Playgroud) cloudant ×6
couchdb ×3
ibm-cloud ×2
json ×2
amazon-s3 ×1
cdn ×1
couchdb-2.0 ×1
couchdb-nano ×1
node.js ×1