couchdb

Couchdb jquery api add Authorization Header

ⅰ亾dé卋堺 提交于 2019-12-13 04:54:13
问题 I want add the Authorization Header to the login request. I try to do that with the code: function dblogin (credential){ $.couch.login({ name:credential.name, password:credential.password, headers: {'Authorization': 'Basic ...'}, success: function (data){console.log("loggato con successo!");}, error: function(status) {console.log("login non riuscito!" + status);} }); } But I see that into HTTP request header the field Authorization is not present. Why? 回答1: From the source code of jquery

CouchDB 2.1.0 starts but the REST API keeps unreachable (connection refused)

微笑、不失礼 提交于 2019-12-13 03:23:11
问题 I'm using CouchDB 2.1.0 on my localhost to sync the data from a web app. Everything was working until I add a new regular user through the PouchDB API and sync the remote database (localhost) with the local one (browser storage). After that, I couldn't access the remote _users database and one of the databases couldn't load even in the list of all databases. I try to refresh Fauxton and, then, it was unreachable. I tried restarting CouchDB in the terminal and I got no feedback for that. When

How to get documents with latest status in case some fields in one document does not existed in another document

此生再无相见时 提交于 2019-12-13 02:27:38
问题 I have some documents like following structure, userid in doc1 is not existed in doc2, doc1: userid='abc', probNumber='123', status='OPEN',... doc2: probNumber='123', status='CLOSE'..... I want to get the latest status document according with the given doc.probNumber , But the key of the view would be doc.userid Or use doc.userid with doc.probNumber combination to achieve on that following userid='abc', probNumber='123', status='CLOSE',... Here is the view and reduce if I used probNumber as

Uploading multiple documents to couchdb giving error

主宰稳场 提交于 2019-12-13 01:56:24
问题 I have to upload bulk document into couchdb but this is not working and giving error. This is what i try to do with curl curl -d '{"docs":[{"key":"baz","name":"bazzel"},{"key":"bar","name":"barry"}]}' -X POST http://127.0.0.1:5984/testdb/_bulk_docs This is the error which comes for this {"error":"bad_content_type","reason":"Content-Type must be application/json"} This curl command is simple copy+paste from wiki of couchdb so ideally this should not be giving error. Is there anything that i am

CouchDB/Couchbase/MongoDB transaction emulation?

五迷三道 提交于 2019-12-13 01:27:40
问题 I've never used CouchDB/MongoDB/Couchbase before and am evaluating them for my application. Generally speaking, they seem to be a very interesting technology that I would like to use. However, coming from an RDBMS background, I am hung up on the lack of transactions. But at the same time, I know that there is going to be much less a need for transactions as I would have in an RDBMS given the way data is organized. That being said, I have the following requirement and not sure if/how I can use

How to use reduce in Fauxton

久未见 提交于 2019-12-13 00:33:38
问题 I've been following some Couch training, but cannot figure out how to use reduce in Fauxton. Selecting '_count' underneath the map area does nothing by itself. I have tried adding it below the map code, but I guess I need to integrate it somehow. In my example I'm trying to count how many times each tag is used in all documents. This is my view code: function (doc, meta) { if(doc.tags) { for(var i in doc.tags) { emit(doc.tags[i],1); } } } function (tag, counts) { var sum = 0; for ( var i = 0;

How to set the content type with Zend_Http_Client on PUT?

冷暖自知 提交于 2019-12-12 19:58:59
问题 Hi I'm refactoring following curl call to a Zend_Http_Client call. This will send a PUT request to a CouchDB database with the given file and set the correct Content-Type for the _attachement. exec( 'curl -s -X PUT ' . $url ' . '--data-binary @\'' . $filePath . '\' -H "Content-Type: ' . $mimeType . '"', $resultJson, $returnCode ); Refactored to Zend_Http_Client I've got the following: $adapter = new Zend_Http_Client_Adapter_Curl(); $client = new Zend_Http_Client(); $client->setAdapter(

Getting CouchDB to work with node.js

前提是你 提交于 2019-12-12 19:22:12
问题 I'm using nodester with iriscouch. I've installed the couchdb-api package. This is my code: console.log("Running"); //Appears in the logs var dbServer = require("couchdb-api").srv('eric-wieser.iriscouch.com'); console.log(dbServer); //Appears in the logs dbServer.info(function (err, response) { console.log("Info!"); //Never executed. Logs show: //Error: ECONNREFUSED, Could not contact DNS servers // at IOWatcher.callback (dns.js:74:15) }); Why is this not working? What is that error trying to

Throw 404 from shows / lists

折月煮酒 提交于 2019-12-12 18:27:51
问题 I query the view like this: /db/_design/myviewname/_view/foo?key=%22ABC123%22 The result is the following: { total_rows: 3, offset: 3, rows: [ ] } All good. Since no doc was found I'd like to throw a 404 from a show or list. Is that possible? 回答1: According to the wiki, you can issue redirect responses via Show/List functions. As such, it is also possible to send out arbitrary HTTP status codes. (like 404) function (head, req) { start({ code: 404 }); } 回答2: I'm not sure if 404 would be the

How to determine current active users in CouchDB?

折月煮酒 提交于 2019-12-12 18:11:54
问题 Is it possible to query current active sessions with couchdb? The server is able to keep track of sessions based on the timeout value so how would I figure out what users have an active session? 回答1: CouchDB doesn't knows anything about active sessions. These "sessions" are actually based on HTTP Cookie, which holds username, timestamp and signature hash. When CouchDB handling the request, it decodes cookie's AuthSession value and verifies that: Username is correct and exists Timestamp + TTL