couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosduclos <...@git.apache.org>
Subject [GitHub] couchdb-nano issue #13: Missing db.attachment.head method
Date Fri, 17 Mar 2017 13:11:42 GMT
GitHub user carlosduclos opened an issue:

    https://github.com/apache/couchdb-nano/issues/13

    Missing db.attachment.head method

    [Original issue](https://github.com/dscape/nano/issues/295)
    
    __hellboy81__
    I should pipe attachment stream to response stream with correct error handling (missing
attachment, etc..)
    
    I am trying to check if attachment exists with db.attachment.head, but I am missing this
method in nano
    
    Ha
    
    ```javascript
    var attachment = db.attachment.get(documentName, attName, function (err) {
       if (err) {
            if (err.statusCode === 404) {
                  // Handle attachment not found
           } else {
                 // Handle other error
          }
       }
    }
    
    // Still executing even if attachment not found
    // Original CouchDB error response is has been sended to client BEFORE callback with error
is called
    attachment.pipe(res)
    ```
    
    __hellboy81__
    As I mentioned db.attachment.get can not work simultaneously with pipe and error handling:
    ```javascript
    var attachment = db.attachment.get(documentName, attName, function (err) {
       if (err) {
            if (err.statusCode === 404) {
                  // Handle attachment not found
           } else {
                 // Handle other error
          }
       }
    
         // Throws error:
         // You cannot pipe after data has been emitted from the response.
         attachment.pipe(res)
    }
    ```


----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message