Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 080FD94C8 for ; Thu, 5 Jan 2012 17:08:03 +0000 (UTC) Received: (qmail 61057 invoked by uid 500); 5 Jan 2012 17:08:02 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 60773 invoked by uid 500); 5 Jan 2012 17:08:01 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 60764 invoked by uid 99); 5 Jan 2012 17:08:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2012 17:08:01 +0000 X-ASF-Spam-Status: No, hits=-2001.6 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2012 17:08:00 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 3005C139CE9 for ; Thu, 5 Jan 2012 17:07:40 +0000 (UTC) Date: Thu, 5 Jan 2012 17:07:40 +0000 (UTC) From: "Jan Lehnardt (Updated) (JIRA)" To: dev@couchdb.apache.org Message-ID: <73322401.10010.1325783260198.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <929529399.587.1307371619787.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (COUCHDB-1188) View query option defaults MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-1188?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jan Lehnardt updated COUCHDB-1188: ---------------------------------- Fix Version/s: (was: 1.2) 1.3 Bump to 1.3.x =20 > View query option defaults > -------------------------- > > Key: COUCHDB-1188 > URL: https://issues.apache.org/jira/browse/COUCHDB-1188 > Project: CouchDB > Issue Type: New Feature > Components: JavaScript View Server > Affects Versions: 1.0.2 > Reporter: David Z=C3=BClke > Priority: Minor > Labels: query, view > Fix For: 1.3 > > > Currently, it's necessary to have intimate-ish knowledge of the inner wor= kings of a view when calling it, e.g.: > http://localhost:5984/mydb/_design/burp/_view/count-laser-beams?group_lev= el=3D2 > If the group level was different, the results returned by the view might = be useless. > Other good examples are "include_docs", "inclusive_end" or "descending". = For instance, views that pull in foreign documents by emitting {_id: ...} a= s a value will only produce useful results when called with "include_docs" = set to true. > I'd suggest a feature where inside a view definition, a new key "query_de= faults" alongside "map" or "reduce" contains a hash map of query option key= s and values that will be used when calling the view unless one of the pre-= defined options is passed as a query argument, in which case the explicitly= given query argument would take precedence. > Example: > "views": { > "talks-by-room": { > "map": "function(doc) {\n\tif(doc.type =3D=3D 'talk' && doc.date_s= tart) {\n\t\temit([doc.room, doc.date_start, 0], doc.name);\n\t\tif(doc.spe= aker) {\n\t\t\temit([doc.room, doc.date_start, 1], {_id: doc.speaker});\n\t= \t}\n\t}\n};", > "query_defaults": { > "include_docs": true > } > } > } > http://localhost:5984/couchcamp/_design/burp/_view/talks-by-room would be= run with include_docs=3Dtrue, but the doc inclusion could be suppressed by= requesting http://localhost:5984/couchcamp/_design/burp/_view/talks-by-roo= m?include_docs=3Dfalse > Alternative names for the new key are "query_options" or "query_option_de= faults". Whilst I prefer "query_options", I think "query_defaults" will be = the better choice as it underlines the nature of the functionality - namely= , that the options defined therein may be overridden by the caller. > Someone on the dev list suggested to use _rewrite, but the idea is that t= he defaults also apply when invoking a list function. So you'd need two rew= rites, one for the view if you want to call it standalone, and one for the = list function. And then you'd still have the issue that the behavior of the= view is changed by the rewrite, which is confusing to anyone looking at th= e view code - you have to look at the rewrite as well to get the whole pict= ure. Not good. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira