From b8670b3da1967f4096a9143badb32877106be514 Mon Sep 17 00:00:00 2001 From: devtanc Date: Tue, 21 Mar 2017 17:43:49 -0600 Subject: [PATCH] Updated documentation for clarification db.view params requirements --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index 21b66d13..dde6d771 100644 --- a/README.md +++ b/README.md @@ -686,6 +686,33 @@ calls a view of the specified design with optional query string additions `params`. if you're looking to filter the view results by key(s) pass an array of keys, e.g `{ keys: ['key1', 'key2', 'key_n'] }`, as `params`. +``` js +alice.view('characters', 'crazy_ones', { + 'key': 'Tea Party', + 'include_docs': true +}, function(err, body) { + if (!err) { + body.rows.forEach(function(doc) { + console.log(doc.value); + }); + } +}); +``` + +``` js +alice.view('characters', 'soldiers', { + 'keys': ['Hearts', 'Clubs'] +}, function(err, body) { + if (!err) { + body.rows.forEach(function(doc) { + console.log(doc.value); + }); + } +}); +``` + +When `params` is not supplied, or no keys are specified, it will simply return all docs in the view. + ``` js alice.view('characters', 'crazy_ones', function(err, body) { if (!err) { @@ -696,6 +723,16 @@ alice.view('characters', 'crazy_ones', function(err, body) { }); ``` +``` js +alice.view('characters', 'crazy_ones', { include_docs: true }, function(err, body) { + if (!err) { + body.rows.forEach(function(doc) { + console.log(doc.value); + }); + } +}); +``` + ### db.viewWithList(designname, viewname, listname, [params], [callback]) calls a list function feeded by the given view of the specified design document.