Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Dominique Sandoz
    @streunerlein
    Hi @elliotatRetireup,
    my first guess would be that it's just too many connections. Try either to use a view with the include_docs parameter (which gives you all the docs) or use the async library with a limit-function (like seriesLimit or similar). Anyway, i would try to load as many docs in as few requests as possible.
    Elliot
    @Elliot128
                            async.forEachOfSeries(body.rows,function(row, key, callback) {
    
    
                                brokerDealers.get(row.id, function(err, body, header) {
    Good idea! I modified it to use async for each series. So now it is calling broker dealers.get then waiting for the callback. Unfortunately the .get command still gives me an error after a few rows.
    etimedout is the error
    Hendrik Roth
    @HendrikRoth
    hmmm i have no idea why, but it seams that nano.multipart.insert breaks my file... my data is a base64 string.
    Dominique Sandoz
    @streunerlein
    @elliotatRetireup no you did not quite understand what i meant. Try not to make a request for every doc, try to make one request in total. Read about views and include_docs. Or alternatively, use a LIMIT function of async (function name has to include "limit" as in eachLimit)
    @henn1nk make sure you took care of these things here http://stackoverflow.com/questions/26739928/couchdb-nano-multipart-insert it should not be b64 if that is not really what you want it to be as a file
    Hendrik Roth
    @HendrikRoth
    @streunerlein found the solution... a base64 string was wrong. i needed to upload blob. works now.
    Elliot
    @Elliot128
    @streunerlein Yes you are correct. I ended up removing the process of getting each doc one at a time. I ended up building a view in couch then grabbing the view via nano. Thanks again for the help, I was just getting started with nodejs at the time.
    And also async was a huge help with that too.
    Hendrik Roth
    @HendrikRoth
    can i do updates in nano, which only updates a part ofd a doc?
    Hendrik Roth
    @HendrikRoth
    i mean couchdb's "update" function
    ah. nano.atomic ... found it. sorry
    Landry Soules
    @landrysoules
    Hello. I'm in trouble with testing nano (with mocha/chai/sinon). I would like to simply verify nano.db.create is called in my code, but I can't get how to do it : var nano = require('nano')('http://localhost:5984'); var mock = sinon.mock(nano.db); mock.expects('db.create').atLeast(1).withExactArgs('bus_stop_dev').returns(true);
    But all I get is TypeError: Attempted to wrap undefined property db.create as function
    Does anybody know how can I get it right, please ?
    Landry Soules
    @landrysoules

    Hello. I'm in trouble with testing nano (with mocha/chai/sinon). I would like to simply verify nano.db.create is called in my code, but I can't get how to do it : var nano = require('nano')('http://localhost:5984'); var mock = sinon.mock(nano.db); mock.expects('db.create').atLeast(1).withExactArgs('bus_stop_dev').returns(true);
    But all I get is TypeError: Attempted to wrap undefined property db.create as function
    Does anybody know how can I get it right, please ?

    Changed my code : mock.expects('create') instead of 'db.create'. Now I get ExpectationError: Expected create(bus_stop_dev) at least once (never called)

    James Howe
    @OrangeDog
    is it possible to use nano through a socks5 proxy?
    James Howe
    @OrangeDog
    or do i need to find an http proxy that uses the socks proxy, then use that?
    James Howe
    @OrangeDog
    I used DeleGate
    hellboy81
    @hellboy81
    Hi. I am trying to (re)write/revision code that pipes input stream to attachment stream
    Callback should be called with response to client, if upload success
    with some JSON data
    where can I call this callback?
    // Should I call result callback from `cb`
    var ws = db.attachment.insert(documentName, attName, null, mimetype, {rev : response.rev}, function(...) {})
    
    // Or should I call in on ('end') event
    ws.on('end',  ...)
    
    // Should I catch write stream errors?
    ws.on('error', function (err) {...})
    
    // Should I catch input stream errors?
    file.on('error',  function(err) {...})
    
    file.pipe(ws)
    hellboy81
    @hellboy81
    Can you verify my code?
    Dominique Sandoz
    @streunerlein
    hi @hellboy81, this is how I do it (read file from disk, pipe to db attachment ):
    // add attachment
            var dbWriteStream = db.attachment.insert(doc._id, filename, null, type, {rev: doc._rev}, uploaded);
            var fileReadStream = fs.createReadStream(file.path);
    
            fileReadStream.on('error', error);
    
            dbWriteStream.on('error', error);
    
            fileReadStream.pipe(dbWriteStream);
    uploaded is the callback that gets called when piping is complete
    then, uploaded():
     function uploaded(err, body) {
              if (err) {
                console.log("[Attachment] Error in upload.");
                if (err.status_code === 409) {
                  console.log('Attachment upload conflict, retry.');
                  addAttachment(req, res);
                  return;
                }
                else {
                  console.log("Unrecoverable error in upload", err);
                  clearTmp();
                  return error(err);
                }
              }
    
              clearTmp();
              ....
    }
    hellboy81
    @hellboy81
    OK, should I handle event "Upload attachment completed" in callback , not in in attachment.on('end',...)
    Why?
    Dominique Sandoz
    @streunerlein
    hm not sure, I never got lucky using on('end', ...)
    also because there are two/three different approaches and i think it had to do with some API changes in streams in node and as well as modules can do it differently
    so i would suggest you to use the variant above, where nano handles it the way it wants
    hellboy81
    @hellboy81
    Only in callback I can get response from CouchDB?
    Dominique Sandoz
    @streunerlein
    yes
    hellboy81
    @hellboy81
    In `on 'end'' this information is not available?
    It's celar
    Dominique Sandoz
    @streunerlein
    when you get the response from CouchDB, it means streaming was ok, then of course, CouchDB errors can occur, but they have nothing to do with the streaming, that's why you have to check err in the callback
    @hellboy81 i have no idea, i just remember that dealing with on('end', ...) was not successful that time i wrote that code
    hellboy81
    @hellboy81
    I must handle only 409 (Conflict error)
    ?
    Dominique Sandoz
    @streunerlein
    you don't, but you can. It can happen, in my app it's quite frequent because there are many writes happening. But usually, Conflict is rare
    But a good programmer handles it in one way or the other ;)
    (my strategy here is to refetch the document to get the latest revision and try again to upload, as long until it works, may not be the best for all applications)
    for "making it work", you don't need to handle 409. Handle it when the problem gets frequent
    hellboy81
    @hellboy81
    OK, which kind of error expecting 409 can happens?
    Dominique Sandoz
    @streunerlein
    that has to do with CouchDBs conflict/revision system
    hellboy81
    @hellboy81
    I think Idea with upload retry is not suitable 4 me
    Dominique Sandoz
    @streunerlein
    read about it in the docs, it can also happen when you update the doc elsewhere
    ok then just go for it and not handle 409 that's perfectly fine