You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stanley Iriele <si...@gmail.com> on 2013/09/05 12:04:41 UTC

Deleting Documents with attachments

Hello all,

I am setting up a Service using attachments and I don't see it explicitly
stated anywhere. If I delete a document with attachments using the DELETE
http verb I am guessing the actual document and attachments are deleted as
well?..or at least follow the "only the _id and _rev left"  model? Or am I
mistaken?...also will using the _deleted true preserve the attachments in
the database?.

Regards,

Stanley

Re: Deleting Documents with attachments

Posted by Robert Newson <rn...@apache.org>.
q) If I delete a document with attachments using the DELETE
http verb I am guessing the actual document and attachments are deleted as
well?

a) yes

q) also will using the _deleted true preserve the attachments in
the database?

a) yes.


On 5 September 2013 11:04, Stanley Iriele <si...@gmail.com> wrote:
> Hello all,
>
> I am setting up a Service using attachments and I don't see it explicitly
> stated anywhere. If I delete a document with attachments using the DELETE
> http verb I am guessing the actual document and attachments are deleted as
> well?..or at least follow the "only the _id and _rev left"  model? Or am I
> mistaken?...also will using the _deleted true preserve the attachments in
> the database?.
>
> Regards,
>
> Stanley

Re: Deleting Documents with attachments

Posted by Alexander Shorin <kx...@gmail.com>.
You can limit attachments __number__ with validate_doc_update function. Like

function(newdoc, olddoc, userctx, secobj){
  if (newdoc._attachments && Object.keys(newdoc._attachments).length >= 20){
    throw({"forbidden": "too many attachments"})
  }
}

However, you couldn't check attachment's size inside validate functions.
--
,,,^..^,,,


On Thu, Sep 5, 2013 at 2:17 PM, Stanley Iriele <si...@gmail.com> wrote:
> That...was more simple than I was expecting...ok ok. I want to limit the
> number of attachments a document can have at any given time to say...20 or
> so...(I could probably find this out just by testing it to be honest)..can
> I use a show function to then call Object.keys on attachments to get that
> number?...the Documentation says it only saves the meta information about
> the data in the Doc...I guess its just going so smoothly its making me kind
> of nervous :-)
>
>
> On Thu, Sep 5, 2013 at 3:07 AM, Alexander Shorin <kx...@gmail.com> wrote:
>
>> > If I delete a document with attachments using the DELETE http verb I am
>> guessing the actual document and attachments are deleted as well?
>>
>> yes
>>
>> > will using the _deleted true preserve the attachments in the database?.
>>
>> yes
>>
>>
>> --
>> ,,,^..^,,,
>>

Re: Deleting Documents with attachments

Posted by Stanley Iriele <si...@gmail.com>.
That...was more simple than I was expecting...ok ok. I want to limit the
number of attachments a document can have at any given time to say...20 or
so...(I could probably find this out just by testing it to be honest)..can
I use a show function to then call Object.keys on attachments to get that
number?...the Documentation says it only saves the meta information about
the data in the Doc...I guess its just going so smoothly its making me kind
of nervous :-)


On Thu, Sep 5, 2013 at 3:07 AM, Alexander Shorin <kx...@gmail.com> wrote:

> > If I delete a document with attachments using the DELETE http verb I am
> guessing the actual document and attachments are deleted as well?
>
> yes
>
> > will using the _deleted true preserve the attachments in the database?.
>
> yes
>
>
> --
> ,,,^..^,,,
>

Re: Deleting Documents with attachments

Posted by Alexander Shorin <kx...@gmail.com>.
> If I delete a document with attachments using the DELETE http verb I am guessing the actual document and attachments are deleted as well?

yes

> will using the _deleted true preserve the attachments in the database?.

yes


--
,,,^..^,,,