incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Shorin <kxe...@gmail.com>
Subject Re: Deleting Documents with attachments
Date Thu, 05 Sep 2013 10:24:39 GMT
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 <siriele2x3@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 <kxepal@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
>>
>>
>> --
>> ,,,^..^,,,
>>

Mime
View raw message