So other than _id(which is uuid CouchDB provides automatically if not specified 
explicitly for the entire database), there is no some elegant(?) way  to 
prevent creating duplicate data inside CouchDB?

Thanks,

> Date: Thu, 18 Dec 2014 23:41:50 +0400
> Subject: Re: Validate_Doc_Update
> From: [email protected]
> To: [email protected]
> 
> No, that's not possible. Validate doc update function only operates
> with document's new version candidate and the "old", current one. It
> cannot not access to others since this will slow down whole the
> process and break eventual consistency. You should run this check
> outside CouchDB in your client code before PUT the document.
> --
> ,,,^..^,,,
> 
> 
> On Thu, Dec 18, 2014 at 10:36 PM, TAE JIN KIM <[email protected]> wrote:
> > Hello,
> >
> > Since CouchDB provides validate_doc_update, I thought that I might be able 
> > to provide some to check duplication here..
> > like...
> >
> > function(newDoc,oldDoc,userCtx) {
> >       if(newDoc.type == "myCustomType") {
> >               // here..something like..
> >               // check newDoc against the existing documents of 
> > "myCustomType" to see whether there was already same data or not..
> >              // for example,
> >             //  
> > getExistingDocumentsByType("myCustomType").forEach(function(doc) {
> >            //               if(newDoc.mydata == doc.mydata) {
> >             //                       ///Boom..throw error..
> >              //              }
> >               //    });
> >            //
> >
> > Is this something possible? Well..obviously there is no provided 
> > getExistingDocumentsByType function from couchdb.....just was trying to 
> > show what I was trying to achieve...
> >
> > So ultimately, my question is that..is there any way I can somehow access 
> > the existing documents from validate_doc_update function?
> >
> > Thanks,
> >
> >
> >
> >
                                          

Reply via email to