From user-return-13826-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri Nov 19 10:54:57 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 70368 invoked from network); 19 Nov 2010 10:54:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Nov 2010 10:54:57 -0000 Received: (qmail 35192 invoked by uid 500); 19 Nov 2010 10:55:27 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 34917 invoked by uid 500); 19 Nov 2010 10:55:27 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 34909 invoked by uid 99); 19 Nov 2010 10:55:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Nov 2010 10:55:26 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of st.fankl.in@googlemail.com designates 209.85.161.180 as permitted sender) Received: from [209.85.161.180] (HELO mail-gx0-f180.google.com) (209.85.161.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Nov 2010 10:55:21 +0000 Received: by gxk8 with SMTP id 8so2719484gxk.11 for ; Fri, 19 Nov 2010 02:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=1zBjpi7J51JvgEirIZoxYWFtjbzkJbVBTwIbr0NLRPQ=; b=WqJz8uzWc5bv4Rb2xEDr87GrRR9BRLgs8NEH/plYXR72D2oLQC1TpxFmNGob9ZkjBn s+H8iPFvvts4IO/7UYms+mGpnDuSkS8Gsr6YqpnLWGt6vfk75k/GNYSbyDM/jAqzCTyD UiGfycthXr5KDl/lfyYtSiiMvwFsD1Cww0DrE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=dF2FunnCJvCmiBiA3GgzwXvDUXxyInr2xibrSxTWOmSceTIi2sbQdWeGXLUxPP4nUt f6ULbecPZQscyS2dKKuit5HEs81/id/cUeruQNTU7/fq3I1NNSj6MYzDbsyyEEcrT/Xn +AHeSfIaqCg6d0aGF1r2NnrAwITlIULyOyWBQ= MIME-Version: 1.0 Received: by 10.100.126.1 with SMTP id y1mr1385145anc.100.1290164100761; Fri, 19 Nov 2010 02:55:00 -0800 (PST) Received: by 10.100.163.13 with HTTP; Fri, 19 Nov 2010 02:55:00 -0800 (PST) Date: Fri, 19 Nov 2010 11:55:00 +0100 Message-ID: Subject: PUT on _update/docid1 but create a new document with _id:docid2? From: Stefan Klein To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi List, i'm toying around with couchDB to create a couchapp to manage bookmarks (yes, i know there are already some). I want to make sure to not have duplicate bookmarks, so i want to use the URL as the _id. With request parameters some URL with are diferent are basicly the same, for example youtube links: http://www.youtube.com/watch?v=3D4jtBQf41Ppc http://www.youtube.com/watch?v=3D4jtBQf41Ppc&feature=3Dchannel I would consider them as the same bookmark, but there is no generic way to tell which request parameters are relevant and which are not. Now one could write a document update handler which is aware of the URL format of youtube, vimeo, ... and everytime the URL format changes or you want to be able to handle an other side you have to edit the update handler. I found another posibility: I created a update handler like: "updates": { =A0=A0=A0 "createBM": "function(doc,req) =A0=A0=A0 { =A0=A0=A0 =A0=A0=A0 if(!doc && ! doc.getId){ =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 getId =3D function(doc,req) { =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // some default way to create an _i= d =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 } =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 getId =3D eval(doc.getId); =A0=A0=A0 =A0=A0=A0 }; =A0=A0=A0 =A0=A0=A0 nDoc =3D {}; =A0=A0=A0 =A0=A0=A0 nDoc._id=3DgetId(doc,req); =A0=A0=A0 =A0=A0=A0 nDoc.url=3Dreq.form.myUrl; =A0=A0=A0 =A0=A0=A0 return[nDoc,\"shiny happy people\"] =A0=A0=A0 }" } and have on document per hostname which holds the logic to determine the relevant URL parameters { "_id": "www.youtube.com", "getId": "function(doc,req) { ytID =3D // get youtube id (v=3D) from the request return \"yt:\" + ytID }" } So if the bookmarklet send a PUT on http://....../_update/createBM/www.youtube.com The update handler will create a document with an id like "yt:4jtBQf41Ppc". Now i'm pretty unsure if this is an evil hack or even a bug in couchdb which get's fixed or if it's just a relay cool feature. regards, Stefan.