dominicbarnes / node-couchdb-api Goto Github PK
View Code? Open in Web Editor NEWAn async wrapper for the CouchDB API, following Node.JS conventions
Home Page: http://dbarnes.info/node-couchdb-api/
License: MIT License
An async wrapper for the CouchDB API, following Node.JS conventions
Home Page: http://dbarnes.info/node-couchdb-api/
License: MIT License
Use a locally-installed mocha, BDD and should.js
You should specify a license under which this is published :)
Try to eliminate the need for client.js
, or at least simplify it.
There are two related issues here:
First, db.tempView expects the query argument in args[2] instead of args[1].
Second, the query argument is not automatically encoded as a querystring, so it has to be passed as
var query = { "qs": { "key": JSON.stringify (["foo", "bar"]) } }
instead of:
var query = { "key": ["foo", "bar"] }
Some example code which illustrates this issue: https://gist.github.com/4518125
it is doc.get() instead of doc.read() but documented wrong on your website. would be cool if you fix this.
http://dominicbarnes.us/node-couchdb-api/api/document.html#read
var couchdb = require('couchdb-api');
var user_pass = 'user:pass';
var dealscc = couchdb.srv(user_pass+'@ip','80');
var local_db = couchdb.srv(user_pass+'@localhost')
//local_db.allDbs();
var dbname = 'backoffice_app';
local_db.db(dbname)
.pull(dealscc.db(dbname),
function(err,data,resp){
console.log(err + ' '+ data + ' ' + resp)
})
the above code times out, i'm not sure what i'm doing wrong
It would be useful to have the option to suppress a JSON parse on data returned from a database. I want to simply buffer the data and pass it on to others. If each NODE server that handles this has to decode and then stringify, well it is a lot of work for the server and not what is needed in every case.
Not so much of an issue as a feature request. Currently I have a JSON string containing data that I want represented as a couch document. With the current API that means parsing the JSON string into an object then iterating over every top-level key and setting its value on doc.body like so;
var e = JSON.parse(data);
var doc = db.doc();
for (key in e) {
doc.body[key] = e[key];
};
It would be much more convenient if I could simply do this;
var doc = db.doc(data); // where 'data' is a JSON string, Buffer containing a JSON string or even a JSON object
Hi!
I am querying a list function (http://dominicbarnes.us/node-couchdb-api/api/view/list.html) in my project and noticed that the behaviour changed from v1.0.0 to v1.1.1.
While the "response" in v1.0.0 returned an object, the "response" in v.1.1.1 contains the unparsed string.
1.0.0: Value: [object Object] - Typeof: object
1.1.1: Value: {"total":19790} - Typeof: string
Use this ddoc for testing:
{
"_id": "_design/list-test",
"language": "javascript",
"views": {
"view-func": {
"map": "function(oDocument)\n{\nemit(oDocument._id, 1)\n}"
}
},
"lists": {
"list-func": "function(oHead, oViewRequest)\n{\n var iTotalSum = 0;\n while (oCurrRow = getRow())\n {\n iTotalSum += oCurrRow.value;\n }\n\n send(toJSON({total: iTotalSum}));\n}"
}
}
and this script for executing with node:
var couchdb = require("couchdb-api");
/** default values: "localhost", 5984 **/
var server = couchdb.srv("localhost", 5984);
var db = server.db("database");
db.ddoc("list-test").view("view-func").list("list-func", function (err, response) {
console.log("Value: "+response+" - Typeof: "+(typeof response));
});
Is this a bug or do i need to call it differently? The documentation says it should be an object (http://dominicbarnes.us/node-couchdb-api/api/callbacks.html)
Thx!
Presently, the library will disconnect when receiving "last_seq" from couchdb when listening to continuous changes, but it won't reconnect. It would be helpful if it did and save the user some code.
The combination of mime-type "application/json" and body ReadableStream results in an attachment containing the following:
{"path":"/tmp/TMPFILE","fd":null,"readable":true,"paused":false,"flags":"r","mode":438,"bufferSize":65536}
I don't think you are suppressing your content handlers when uploading streaming attachments.
We have a handful of apps that are using couchdb (and in particular, the node-couchdb-api module).
Unfortunately, trying to migrate from 0.6 (which worked well) to 0.8 failed. I traced the issue (at least for us) down to how authentication with the couchdb server was being handled. For some reason there was a leading square bracket ([
) when the url was parsed.
With a little workaround to add in authentication after creation, everything seems to be working fine in 0.8!
Essentially, you just create the database server connection as if there is no authentication, then add the auth param to the server's url setter. Here's what we ended up doing.
var dbServer = couchdb.srv(COUCHDB_HOST, COUCHDB_PORT, false, false);
dbServer.url = {
hostname: COUCHDB_HOST,
port: COUCHDB_PORT,
protocol: COUCHDB_HTTP,
auth: COUCHDB_AUTH
};
We'd love to keep using couchdb and this module, but having things break when moving to the current stable version of node is a bit frustrating. Perhaps there's some MongoDB in our future, but until then hopefully this will help others migrate their couch apps, too. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.