nlight-jdev / jcouchdb

Automatically exported from code.google.com/p/jcouchdb
Other
0 stars 0 forks source link

New Feature Patch Query List function with multiple keys #45

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is an addition to the Database object that will allow you to pass in a
List function, View function and a List of keys to be processed by the
views along with an Options object. This is so you can post process the
results of a View thru a List with a POST of multiple keys.

    /**
     * Queries the specified list function with the specified view and the
specified Keys
     * @param listName Name of list included design doc (e.g.
"designDocId/listName")
     * @param viewName view name without design document
     * @param keys list of keys to apply to the view
     * @param options query options
     * @return response
     */
    public Response queryList(final String listName, final String viewName,
final List<List<String>> keys, final Options options)
    {
        String uri = "/" + name + "/" +
getDesignURIFromNameAndInfix(listName, LIST_DOCUMENT_INFIX) + "/" +
encodeURL(viewName);

        if (options != null)
        {
            uri += options.toQuery();
        }
        final Map<String, List<List<String>>> map = new HashMap<String,
List<List<String>>>(1);
        map.put("keys", keys);
        return server.post(uri, jsonGenerator.forValue(map));  
    }

Original issue reported on code.google.com by jarrod.r...@gmail.com on 19 Apr 2010 at 11:43

Attachments:

GoogleCodeExporter commented 8 years ago
Why is keys List<List<String>>? can't find anything in the CouchDB documentation
about using list of lists and org.jcouchdb.db.Database.queryViewByKeys(String,
Class<V>, List<?>, Options, JSONParser) works fine with List<String>.

Original comment by ff...@gmx.de on 14 May 2010 at 1:05

GoogleCodeExporter commented 8 years ago
I was using keys that were lists themselves in my particular case. List<?> 
should be
fine. http://www.vertigrated.com/blog/2010/04/generic-ad-hoc-queries-in-couchdb/

Original comment by jarrod.r...@gmail.com on 15 May 2010 at 2:52