incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Bardubitzki <step...@bardubitzki.com>
Subject Re: Document update conflict
Date Sat, 07 Jul 2012 03:30:58 GMT
Never mind, forgot the attachmentId.

On 12-07-06 07:21 PM, Stephan Bardubitzki wrote:
> I'm using node and cradle to upload and save attachments (in this case 
> images), however, I get a
>
> error: conflict
> reason: "document update conflict"
> status: 409.
>
> The right doc._id and doc._rev attributes are transmitted, what else 
> can cause this error?
>
> Here is my server side code:
>
> exports.addLogo = function(req, res) {
>     var business,
>         businessName = req.body.businessname;
>     if ( req.files ) {
>         // get business data
>         db.view('business/getByBusinessName', { key: businessName }, 
> function(err, doc) {
>             if ( err ) {
>                 res.send({ header: 'Upload business logo', message: 
> err.reason, type: 'error'});
>             }
>             else {
>                 business = doc[0].value;
>                 // add business logo to couchdb document
>                 db.saveAttachment(
>                     business._id,
>                     business._rev,
>                     req.files.logo.type,
>                     fs.createReadStream(req.files.logo.path),
>                     function( att_err, data ) {
>                         if ( att_err ) {
>                             console.log('Logo upload error: ' + 
> att_err.reason);
>                             res.send({ header: 'Upload business logo', 
> message: att_err.reason, type: 'error'});
>                         }
>                         else {
>                             console.log(data);
>                             res.send({ response: 'ok' });
>                         }
>                 });
>             }
>         });
>
>     }
> }; 



Mime
View raw message