leanback 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +65 -14
- data/README.md +465 -33
- data/Rakefile +8 -17
- data/VERSION +1 -1
- data/leanback.gemspec +26 -85
- data/lib/leanback.rb +129 -587
- data/spec/leanback_spec.rb +356 -0
- metadata +40 -117
- data/Changelog.rdoc +0 -146
- data/documentation/static/2011/11/20/i-moved-leanback-documentation/index.html +0 -180
- data/documentation/static/2011/11/20/index.html +0 -146
- data/documentation/static/2011/11/index.html +0 -146
- data/documentation/static/2011/index.html +0 -146
- data/documentation/static/2013/06/02/index.html +0 -146
- data/documentation/static/2013/06/02/released-leanback-v0-3-4/index.html +0 -180
- data/documentation/static/2013/06/09/index.html +0 -146
- data/documentation/static/2013/06/09/released-leanback-v0-4-0/index.html +0 -179
- data/documentation/static/2013/06/index.html +0 -158
- data/documentation/static/2013/index.html +0 -158
- data/documentation/static/author/admin/index.html +0 -175
- data/documentation/static/basic-couchdb-operations/index.html +0 -259
- data/documentation/static/category/uncategorized/index.html +0 -170
- data/documentation/static/couchdb-configuration/index.html +0 -189
- data/documentation/static/couchdb-security/index.html +0 -218
- data/documentation/static/count-by-multiple-documents/index.html +0 -221
- data/documentation/static/count-documents-by-key/index.html +0 -177
- data/documentation/static/css/2c-l-fixed.css +0 -1
- data/documentation/static/css/2c-l-fixed.dev.css +0 -62
- data/documentation/static/css/2c-r-fixed.css +0 -1
- data/documentation/static/css/2c-r-fixed.dev.css +0 -60
- data/documentation/static/css/3c-c-fixed.css +0 -1
- data/documentation/static/css/3c-c-fixed.dev.css +0 -84
- data/documentation/static/css/3c-l-fixed.css +0 -1
- data/documentation/static/css/3c-l-fixed.dev.css +0 -61
- data/documentation/static/css/3c-r-fixed.css +0 -1
- data/documentation/static/css/3c-r-fixed.dev.css +0 -62
- data/documentation/static/css/holy-grail-fluid.css +0 -5
- data/documentation/static/css/plugins.css +0 -5
- data/documentation/static/css/print.css +0 -5
- data/documentation/static/css/screen.css +0 -1
- data/documentation/static/design-documents-and-permanent-views/index.html +0 -454
- data/documentation/static/error-handling/index.html +0 -157
- data/documentation/static/find-document-by-multiple-keys/index.html +0 -269
- data/documentation/static/find-documents-by-key/index.html +0 -243
- data/documentation/static/index.html +0 -161
- data/documentation/static/leanback/index.html +0 -130
- data/documentation/static/leanback/installation/index.html +0 -119
- data/documentation/static/setting-the-bind_address-port/index.html +0 -151
- data/documentation/static/style.css +0 -16
- data/spec/admin_party/database_spec.rb +0 -400
- data/spec/no_admin_party/cloudant_spec.rb +0 -365
- data/spec/no_admin_party/database_spec.rb +0 -491
- data/spec/no_admin_party/non_admin_user_spec.rb +0 -67
- data/test/helper.rb +0 -18
- data/test/main.rb +0 -295
- data/test/my_view.json +0 -8
- data/test/my_views.json +0 -8
- data/test/start.json +0 -8
- data/test/test_leanback.rb +0 -319
- data/test/view_age.json +0 -8
@@ -1,157 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>Error handling</title>
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/themes/hybrid/style.css" type="text/css" media="all" />
|
8
|
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
9
|
-
<link rel="pingback" href="http://www.whisperservers.com/leanback/xmlrpc.php" />
|
10
|
-
|
11
|
-
<meta name="generator" content="WordPress 3.5.1 - really-static 0.5" />
|
12
|
-
<meta name="template" content="Hybrid 1.0" />
|
13
|
-
<meta name="robots" content="index,follow" />
|
14
|
-
<meta name="author" content="admin" />
|
15
|
-
<meta name="copyright" content="Copyright (c) November 2011" />
|
16
|
-
<meta name="revised" content="Sunday, November 20th, 2011, 3:27 am" />
|
17
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/feed/" />
|
18
|
-
|
19
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
|
20
|
-
<link rel='prev' title='Working with CouchDB views' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/' />
|
21
|
-
<link rel='next' title='CouchDB Configuration' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/' />
|
22
|
-
<link rel='canonical' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/' />
|
23
|
-
|
24
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/plugins/wp-syntax/wp-syntax.css" type="text/css" media="screen" />
|
25
|
-
|
26
|
-
</head>
|
27
|
-
|
28
|
-
<body class="wordpress ltr en_US parent-theme y2013 m06 d09 h16 sunday logged-out singular singular-page singular-page-59 page-template-default page-59 primary-active secondary-inactive subsidiary-inactive">
|
29
|
-
|
30
|
-
|
31
|
-
<div id="body-container">
|
32
|
-
|
33
|
-
|
34
|
-
<div id="header-container">
|
35
|
-
|
36
|
-
<div id="header">
|
37
|
-
|
38
|
-
<div id="site-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home"><span>Leanback</span></a></div>
|
39
|
-
<div id="site-description"><span>Simple Ruby interface to CouchDB</span></div>
|
40
|
-
|
41
|
-
</div><!-- #header -->
|
42
|
-
|
43
|
-
</div><!-- #header-container -->
|
44
|
-
|
45
|
-
|
46
|
-
<div id="container">
|
47
|
-
|
48
|
-
|
49
|
-
<div id="content" class="hfeed content">
|
50
|
-
|
51
|
-
<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">Browse:</span></span> <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home" class="trail-begin">Home</a> <span class="sep">/</span> <span class="trail-end">Error handling</span></div></div>
|
52
|
-
|
53
|
-
<div id="post-59" class="hentry page publish post-1 odd author-admin">
|
54
|
-
|
55
|
-
<h1 class="page-title entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/" title="Error handling" rel="bookmark">Error handling</a></h1>
|
56
|
-
<div class="entry-content">
|
57
|
-
<p>Leanback raises a CouchdbException when things go wrong.</p>
|
58
|
-
<p>Attempting to create a database that already exists</p>
|
59
|
-
|
60
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> <span style="color:#9966CC; font-weight:bold;">begin</span>
|
61
|
-
Couchdb.<span style="color:#9900CC;">create</span> <span style="color:#996600;">'contacts'</span>
|
62
|
-
<span style="color:#9966CC; font-weight:bold;">rescue</span> CouchdbException <span style="color:#006600; font-weight:bold;">=></span> e
|
63
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Error message: "</span> <span style="color:#006600; font-weight:bold;">+</span> e.<span style="color:#9900CC;">to_s</span>
|
64
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Error value: "</span> <span style="color:#006600; font-weight:bold;">+</span> e.<span style="color:#9900CC;">error</span>
|
65
|
-
<span style="color:#9966CC; font-weight:bold;">end</span>
|
66
|
-
|
67
|
-
<span style="color:#008000; font-style:italic;"># => Error message: CouchDB: Error - file_exists. Reason - The database could not be created, the file already exists.</span>
|
68
|
-
<span style="color:#008000; font-style:italic;"># Error value: file_exists</span></pre></div></div>
|
69
|
-
|
70
|
-
<p>Attempting to delete a database that doesn’t exist</p>
|
71
|
-
|
72
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> <span style="color:#9966CC; font-weight:bold;">begin</span>
|
73
|
-
Couchdb.<span style="color:#9900CC;">delete</span> <span style="color:#996600;">'buildings'</span>
|
74
|
-
<span style="color:#9966CC; font-weight:bold;">rescue</span> CouchdbException <span style="color:#006600; font-weight:bold;">=></span> e
|
75
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Error message: "</span> <span style="color:#006600; font-weight:bold;">+</span> e.<span style="color:#9900CC;">to_s</span>
|
76
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Error value: "</span> <span style="color:#006600; font-weight:bold;">+</span> e.<span style="color:#9900CC;">error</span>
|
77
|
-
<span style="color:#9966CC; font-weight:bold;">end</span>
|
78
|
-
|
79
|
-
<span style="color:#008000; font-style:italic;"># => Error message: CouchDB: Error - not_found. Reason - missing</span>
|
80
|
-
<span style="color:#008000; font-style:italic;"># Error value: not_found</span></pre></div></div>
|
81
|
-
|
82
|
-
<p>Attempting to query a permanent view that doesn’t exist</p>
|
83
|
-
|
84
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> <span style="color:#9966CC; font-weight:bold;">begin</span>
|
85
|
-
view = <span style="color:#006600; font-weight:bold;">{</span> <span style="color:#ff3333; font-weight:bold;">:database</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"contacts"</span>,
|
86
|
-
<span style="color:#ff3333; font-weight:bold;">:design_doc</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'more_views'</span>,
|
87
|
-
<span style="color:#ff3333; font-weight:bold;">:view</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'get_user_email'</span><span style="color:#006600; font-weight:bold;">}</span>
|
88
|
-
Couchdb.<span style="color:#9900CC;">find</span> view
|
89
|
-
<span style="color:#9966CC; font-weight:bold;">rescue</span> CouchdbException <span style="color:#006600; font-weight:bold;">=></span> e
|
90
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Error message: "</span> <span style="color:#006600; font-weight:bold;">+</span> e.<span style="color:#9900CC;">to_s</span>
|
91
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Error value: "</span> <span style="color:#006600; font-weight:bold;">+</span> e.<span style="color:#9900CC;">error</span>
|
92
|
-
<span style="color:#9966CC; font-weight:bold;">end</span>
|
93
|
-
|
94
|
-
<span style="color:#008000; font-style:italic;"># => Error message: CouchDB: Error - not_found. Reason - missing_named_view</span>
|
95
|
-
<span style="color:#008000; font-style:italic;"># Error value: not_found</span></pre></div></div>
|
96
|
-
|
97
|
-
<p>You can always check the information passed to the Exception.</p>
|
98
|
-
</div><!-- .entry-content -->
|
99
|
-
|
100
|
-
|
101
|
-
</div><!-- .hentry -->
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
</div><!-- .content .hfeed -->
|
110
|
-
|
111
|
-
|
112
|
-
<div id="primary" class="sidebar aside">
|
113
|
-
|
114
|
-
|
115
|
-
<div id="hybrid-nav-menu-3" class="widget nav-menu widget-nav-menu"><div class="widget-wrap widget-inside"><h3 class="widget-title">Leanback</h3><div class="menu-sidebar-container"><ul id="menu-sidebar" class="nav-menu"><li id="menu-item-13" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-13"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/">Leanback</a><ul class="sub-menu"><li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/installation/">Install</a></li><li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/">Basic CouchDB Operations</a></li><li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/">Find documents by key</a></li><li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-167"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/">Find document by multiple Keys</a></li><li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/">Count documents by key</a></li><li id="menu-item-175" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-175"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/">Count documents by multiple keys</a></li><li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/">Working with CouchDB views</a></li><li id="menu-item-67" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-59 current_page_item menu-item-67"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/">Error handling</a></li><li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-96"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/">CouchDB Configuration</a></li><li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">CouchDB Security</a></li><li id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">CouchDB Bind_Address & Port</a></li></ul></li><li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-142"><a href="https://github.com/obi-a/leanback/blob/master/Changelog.rdoc">Changes</a></li><li id="menu-item-78" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-78"><a href="https://github.com/obi-a/leanback">Source Code</a></li></ul></div></div></div>
|
116
|
-
|
117
|
-
</div><!-- #primary .aside -->
|
118
|
-
|
119
|
-
|
120
|
-
</div><!-- #container -->
|
121
|
-
|
122
|
-
<div id="footer-container">
|
123
|
-
|
124
|
-
|
125
|
-
<div id="footer">
|
126
|
-
|
127
|
-
<div class="footer-insert"><p class="copyright">Copyright © 2013 <a href="http://obi-akubue.org">obi-akubue.org</a>.</p></div>
|
128
|
-
</div><!-- #footer -->
|
129
|
-
|
130
|
-
|
131
|
-
</div><!-- #footer-container -->
|
132
|
-
|
133
|
-
</div><!-- #body-container -->
|
134
|
-
|
135
|
-
|
136
|
-
<script type="text/javascript">
|
137
|
-
|
138
|
-
var _gaq = _gaq || [];
|
139
|
-
_gaq.push(['_setAccount', 'UA-20190925-6']);
|
140
|
-
_gaq.push(['_trackPageview']);
|
141
|
-
|
142
|
-
(function() {
|
143
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
144
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
145
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
146
|
-
})();
|
147
|
-
</script>
|
148
|
-
|
149
|
-
<a style='color:transparent;position:absolute;left:-99999px;z-index:-99999' href='http://www.wpdownloadmanager.com/' title='Premium Wordpress Plugin download manager'>Premium Wordpress Plugin</a>
|
150
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-content/themes/hybrid/library/js/drop-downs.js?ver=20110705'></script>
|
151
|
-
|
152
|
-
</body>
|
153
|
-
</html>
|
154
|
-
<!-- Dynamic page generated in 0.455 seconds. -->
|
155
|
-
<!-- Cached page generated by WP-Super-Cache on 2013-06-09 16:30:33 -->
|
156
|
-
|
157
|
-
<!-- super cache -->
|
@@ -1,269 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>Find document by multiple Keys</title>
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/themes/hybrid/style.css" type="text/css" media="all" />
|
8
|
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
9
|
-
<link rel="pingback" href="http://www.whisperservers.com/leanback/xmlrpc.php" />
|
10
|
-
|
11
|
-
<meta name="generator" content="WordPress 3.5.1 - really-static 0.5" />
|
12
|
-
<meta name="template" content="Hybrid 1.0" />
|
13
|
-
<meta name="robots" content="index,follow" />
|
14
|
-
<meta name="author" content="admin" />
|
15
|
-
<meta name="copyright" content="Copyright (c) June 2013" />
|
16
|
-
<meta name="revised" content="Sunday, June 9th, 2013, 3:51 pm" />
|
17
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/feed/" />
|
18
|
-
|
19
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Find document by multiple Keys Comments Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/feed/" />
|
20
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/comment-reply.min.js?ver=3.5.1'></script>
|
21
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
|
22
|
-
<link rel='prev' title='Count documents by key' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/' />
|
23
|
-
<link rel='next' title='Count documents by multiple keys' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/' />
|
24
|
-
<link rel='canonical' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/' />
|
25
|
-
|
26
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/plugins/wp-syntax/wp-syntax.css" type="text/css" media="screen" />
|
27
|
-
|
28
|
-
</head>
|
29
|
-
|
30
|
-
<body class="wordpress ltr en_US parent-theme y2013 m06 d09 h16 sunday logged-out singular singular-page singular-page-164 page-template-default page-164 primary-active secondary-inactive subsidiary-inactive">
|
31
|
-
|
32
|
-
|
33
|
-
<div id="body-container">
|
34
|
-
|
35
|
-
|
36
|
-
<div id="header-container">
|
37
|
-
|
38
|
-
<div id="header">
|
39
|
-
|
40
|
-
<div id="site-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home"><span>Leanback</span></a></div>
|
41
|
-
<div id="site-description"><span>Simple Ruby interface to CouchDB</span></div>
|
42
|
-
|
43
|
-
</div><!-- #header -->
|
44
|
-
|
45
|
-
</div><!-- #header-container -->
|
46
|
-
|
47
|
-
|
48
|
-
<div id="container">
|
49
|
-
|
50
|
-
|
51
|
-
<div id="content" class="hfeed content">
|
52
|
-
|
53
|
-
<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">Browse:</span></span> <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home" class="trail-begin">Home</a> <span class="sep">/</span> <span class="trail-end">Find document by multiple Keys</span></div></div>
|
54
|
-
|
55
|
-
<div id="post-164" class="hentry page publish post-1 odd author-admin">
|
56
|
-
|
57
|
-
<h1 class="page-title entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/" title="Find document by multiple Keys" rel="bookmark">Find document by multiple Keys</a></h1>
|
58
|
-
<div class="entry-content">
|
59
|
-
<p>First we login to CouchDB and generate the auth_session token for making requests.</p>
|
60
|
-
|
61
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hash = Couchdb.<span style="color:#9900CC;">login</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'samson'</span>,password =<span style="color:#996600;">'sam123'</span><span style="color:#006600; font-weight:bold;">)</span>
|
62
|
-
auth_session = hash<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"AuthSession"</span><span style="color:#006600; font-weight:bold;">]</span></pre></div></div>
|
63
|
-
|
64
|
-
<p>To retrieve all documents in the friends database with gender = male and age = 34</p>
|
65
|
-
|
66
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
67
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
68
|
-
|
69
|
-
<p>To retrieve all documents in the friends database with gender = male, age = 34 and lastname = smith</p>
|
70
|
-
|
71
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span>, <span style="color:#ff3333; font-weight:bold;">:lastname</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'smith'</span><span style="color:#006600; font-weight:bold;">}</span>
|
72
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
73
|
-
|
74
|
-
<p>If you are running an admin party (i.e you have no admins in CouchDB), simply use the same methods, with no auth_session parameter.</p>
|
75
|
-
|
76
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
77
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span><span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
78
|
-
|
79
|
-
<p><strong>Options</strong><br />
|
80
|
-
A set of options can be used to manipulate the results.</p>
|
81
|
-
<p><strong>limits</strong><br />
|
82
|
-
To limit the results. Example to return the first 20 documents with age=34 and gender = male:</p>
|
83
|
-
|
84
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:limit <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
85
|
-
keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
86
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
87
|
-
|
88
|
-
<p>For admin party,</p>
|
89
|
-
|
90
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:limit <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
91
|
-
keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
92
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,<span style="color:#996600;">""</span>, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
93
|
-
|
94
|
-
<p><strong>skip</strong><br />
|
95
|
-
To skip the first 10 results and return the next 20:</p>
|
96
|
-
|
97
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:skip <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">10</span>,:limit <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
98
|
-
keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
99
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
100
|
-
|
101
|
-
<p>Note that the skip option is considered a relatively expensive CouchDB operation because the rows are still processed and skipped.</p>
|
102
|
-
<p>To skip the first 20 results and return the rest:</p>
|
103
|
-
|
104
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:skip <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
105
|
-
keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
106
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
107
|
-
|
108
|
-
<p><strong>descending</strong><br />
|
109
|
-
Couchdb returns results in ascending order by default, to change it to descending order:</p>
|
110
|
-
|
111
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:descending <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">}</span>
|
112
|
-
keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
113
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
114
|
-
|
115
|
-
<p><strong>startkey & endkey</strong><br />
|
116
|
-
startkey & endkey don’t work with find_by_keys() because find_by_keys already uses them. See the next section for details.</p>
|
117
|
-
<p><strong>How it works</strong><br />
|
118
|
-
The method</p>
|
119
|
-
|
120
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
121
|
-
Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
122
|
-
|
123
|
-
<p>sends a</p>
|
124
|
-
|
125
|
-
<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">GET http://127.0.0.1:5984/friends/_design/gender_age_keys_finder/_view/find_by_keys_gender_age?startkey=["male","34"]&endkey=["male","34"]</pre></div></div>
|
126
|
-
|
127
|
-
<p>This returns all friends with gender = male and age = 34. Leanback will parse the native JSON results to return only the data. If the design_document (_design/gender_age_keys_finder) and the view (find_by_keys_gender_age) doesn’t exist, Leanback will create it in the database. See the source for the generated design_document;</p>
|
128
|
-
|
129
|
-
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">{</span>
|
130
|
-
<span style="color: #3366CC;">"_id"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"_design/gender_age_keys_finder"</span><span style="color: #339933;">,</span>
|
131
|
-
<span style="color: #3366CC;">"_rev"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"1-92674ebbb4bca65add937f764b37623d"</span><span style="color: #339933;">,</span>
|
132
|
-
<span style="color: #3366CC;">"language"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"javascript"</span><span style="color: #339933;">,</span>
|
133
|
-
<span style="color: #3366CC;">"views"</span><span style="color: #339933;">:</span> <span style="color: #009900;">{</span>
|
134
|
-
<span style="color: #3366CC;">"find_by_keys_gender_age"</span><span style="color: #339933;">:</span> <span style="color: #009900;">{</span>
|
135
|
-
<span style="color: #3366CC;">"map"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"function(doc){ if(doc.gender && doc.age) emit([doc.gender,doc.age],doc);}"</span>
|
136
|
-
<span style="color: #009900;">}</span>
|
137
|
-
<span style="color: #009900;">}</span>
|
138
|
-
<span style="color: #009900;">}</span></pre></div></div>
|
139
|
-
|
140
|
-
<p><strong>Usage</strong><br />
|
141
|
-
You can do</p>
|
142
|
-
|
143
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> keys = <span style="color:#006600; font-weight:bold;">{</span>:gender <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'male'</span>,:age <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'34'</span><span style="color:#006600; font-weight:bold;">}</span>
|
144
|
-
docs = Couchdb.<span style="color:#9900CC;">find_by_keys</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'friends'</span>, <span style="color:#ff3333; font-weight:bold;">:keys</span> <span style="color:#006600; font-weight:bold;">=></span> keys<span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
145
|
-
docs.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>d<span style="color:#006600; font-weight:bold;">|</span>
|
146
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"_rev"</span><span style="color:#006600; font-weight:bold;">]</span>
|
147
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"_id"</span><span style="color:#006600; font-weight:bold;">]</span>
|
148
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"firstname"</span><span style="color:#006600; font-weight:bold;">]</span>
|
149
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"lastname"</span><span style="color:#006600; font-weight:bold;">]</span>
|
150
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"age"</span><span style="color:#006600; font-weight:bold;">]</span>
|
151
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"gender"</span><span style="color:#006600; font-weight:bold;">]</span>
|
152
|
-
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
|
153
|
-
|
154
|
-
</div><!-- .entry-content -->
|
155
|
-
|
156
|
-
|
157
|
-
</div><!-- .hentry -->
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
<div id="disqus_thread">
|
162
|
-
</div>
|
163
|
-
|
164
|
-
<script type="text/javascript">
|
165
|
-
/* <![CDATA[ */
|
166
|
-
var disqus_url = 'http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/';
|
167
|
-
var disqus_identifier = '164 http://www.whisperservers.com/leanback/?page_id=164';
|
168
|
-
var disqus_container_id = 'disqus_thread';
|
169
|
-
var disqus_domain = 'disqus.com';
|
170
|
-
var disqus_shortname = 'obi-akubue';
|
171
|
-
var disqus_title = "Find document by multiple Keys";
|
172
|
-
var disqus_config = function () {
|
173
|
-
var config = this; // Access to the config object
|
174
|
-
|
175
|
-
/*
|
176
|
-
All currently supported events:
|
177
|
-
* preData — fires just before we request for initial data
|
178
|
-
* preInit - fires after we get initial data but before we load any dependencies
|
179
|
-
* onInit - fires when all dependencies are resolved but before dtpl template is rendered
|
180
|
-
* afterRender - fires when template is rendered but before we show it
|
181
|
-
* onReady - everything is done
|
182
|
-
*/
|
183
|
-
|
184
|
-
config.callbacks.preData.push(function() {
|
185
|
-
// clear out the container (its filled for SEO/legacy purposes)
|
186
|
-
document.getElementById(disqus_container_id).innerHTML = '';
|
187
|
-
});
|
188
|
-
config.callbacks.onReady.push(function() {
|
189
|
-
// sync comments in the background so we don't block the page
|
190
|
-
DISQUS.request.get('?cf_action=sync_comments&post_id=164');
|
191
|
-
});
|
192
|
-
};
|
193
|
-
var facebookXdReceiverPath = 'http://www.whisperservers.com/leanback/wp-content/plugins/disqus-comment-system/xd_receiver.htm';
|
194
|
-
/* ]]> */
|
195
|
-
</script>
|
196
|
-
|
197
|
-
<script type="text/javascript">
|
198
|
-
/* <![CDATA[ */
|
199
|
-
var DsqLocal = {
|
200
|
-
'trackbacks': [
|
201
|
-
],
|
202
|
-
'trackback_url': "http:\/\/www.whisperservers.com\/leanback\/wp-content\/plugins\/really-static\/static\/find-document-by-multiple-keys\/trackback\/" };
|
203
|
-
/* ]]> */
|
204
|
-
</script>
|
205
|
-
|
206
|
-
<script type="text/javascript">
|
207
|
-
/* <![CDATA[ */
|
208
|
-
(function() {
|
209
|
-
var dsq = document.createElement('script'); dsq.type = 'text/javascript';
|
210
|
-
dsq.async = true;
|
211
|
-
dsq.src = 'http://' + disqus_shortname + '.' + disqus_domain + '/embed.js?pname=wordpress&pver=2.67';
|
212
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
213
|
-
})();
|
214
|
-
/* ]]> */
|
215
|
-
</script>
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
</div><!-- .content .hfeed -->
|
222
|
-
|
223
|
-
|
224
|
-
<div id="primary" class="sidebar aside">
|
225
|
-
|
226
|
-
|
227
|
-
<div id="hybrid-nav-menu-3" class="widget nav-menu widget-nav-menu"><div class="widget-wrap widget-inside"><h3 class="widget-title">Leanback</h3><div class="menu-sidebar-container"><ul id="menu-sidebar" class="nav-menu"><li id="menu-item-13" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-13"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/">Leanback</a><ul class="sub-menu"><li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/installation/">Install</a></li><li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/">Basic CouchDB Operations</a></li><li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/">Find documents by key</a></li><li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-164 current_page_item menu-item-167"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/">Find document by multiple Keys</a></li><li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/">Count documents by key</a></li><li id="menu-item-175" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-175"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/">Count documents by multiple keys</a></li><li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/">Working with CouchDB views</a></li><li id="menu-item-67" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-67"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/">Error handling</a></li><li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-96"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/">CouchDB Configuration</a></li><li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">CouchDB Security</a></li><li id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">CouchDB Bind_Address & Port</a></li></ul></li><li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-142"><a href="https://github.com/obi-a/leanback/blob/master/Changelog.rdoc">Changes</a></li><li id="menu-item-78" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-78"><a href="https://github.com/obi-a/leanback">Source Code</a></li></ul></div></div></div>
|
228
|
-
|
229
|
-
</div><!-- #primary .aside -->
|
230
|
-
|
231
|
-
|
232
|
-
</div><!-- #container -->
|
233
|
-
|
234
|
-
<div id="footer-container">
|
235
|
-
|
236
|
-
|
237
|
-
<div id="footer">
|
238
|
-
|
239
|
-
<div class="footer-insert"><p class="copyright">Copyright © 2013 <a href="http://obi-akubue.org">obi-akubue.org</a>.</p></div>
|
240
|
-
</div><!-- #footer -->
|
241
|
-
|
242
|
-
|
243
|
-
</div><!-- #footer-container -->
|
244
|
-
|
245
|
-
</div><!-- #body-container -->
|
246
|
-
|
247
|
-
|
248
|
-
<script type="text/javascript">
|
249
|
-
|
250
|
-
var _gaq = _gaq || [];
|
251
|
-
_gaq.push(['_setAccount', 'UA-20190925-6']);
|
252
|
-
_gaq.push(['_trackPageview']);
|
253
|
-
|
254
|
-
(function() {
|
255
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
256
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
257
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
258
|
-
})();
|
259
|
-
</script>
|
260
|
-
|
261
|
-
<a style='color:transparent;position:absolute;left:-99999px;z-index:-99999' href='http://www.wpdownloadmanager.com/' title='Premium Wordpress Plugin download manager'>Premium Wordpress Plugin</a>
|
262
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-content/themes/hybrid/library/js/drop-downs.js?ver=20110705'></script>
|
263
|
-
|
264
|
-
</body>
|
265
|
-
</html>
|
266
|
-
<!-- Dynamic page generated in 0.497 seconds. -->
|
267
|
-
<!-- Cached page generated by WP-Super-Cache on 2013-06-09 16:30:47 -->
|
268
|
-
|
269
|
-
<!-- super cache -->
|
@@ -1,243 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en-US">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>Find documents by key</title>
|
6
|
-
|
7
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/themes/hybrid/style.css" type="text/css" media="all" />
|
8
|
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
9
|
-
<link rel="pingback" href="http://www.whisperservers.com/leanback/xmlrpc.php" />
|
10
|
-
|
11
|
-
<meta name="generator" content="WordPress 3.5.1 - really-static 0.5" />
|
12
|
-
<meta name="template" content="Hybrid 1.0" />
|
13
|
-
<meta name="robots" content="index,follow" />
|
14
|
-
<meta name="author" content="admin" />
|
15
|
-
<meta name="copyright" content="Copyright (c) November 2011" />
|
16
|
-
<meta name="revised" content="Sunday, June 2nd, 2013, 6:08 pm" />
|
17
|
-
<link rel="alternate" type="application/rss+xml" title="Leanback » Feed" href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/feed/" />
|
18
|
-
|
19
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
|
20
|
-
<link rel='prev' title='Basic CouchDB Operations' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/' />
|
21
|
-
<link rel='next' title='Working with CouchDB views' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/' />
|
22
|
-
<link rel='canonical' href='http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/' />
|
23
|
-
|
24
|
-
<link rel="stylesheet" href="http://www.whisperservers.com/leanback/wp-content/plugins/wp-syntax/wp-syntax.css" type="text/css" media="screen" />
|
25
|
-
|
26
|
-
</head>
|
27
|
-
|
28
|
-
<body class="wordpress ltr en_US parent-theme y2013 m06 d09 h16 sunday logged-out singular singular-page singular-page-26 page-template-default page-26 primary-active secondary-inactive subsidiary-inactive">
|
29
|
-
|
30
|
-
|
31
|
-
<div id="body-container">
|
32
|
-
|
33
|
-
|
34
|
-
<div id="header-container">
|
35
|
-
|
36
|
-
<div id="header">
|
37
|
-
|
38
|
-
<div id="site-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home"><span>Leanback</span></a></div>
|
39
|
-
<div id="site-description"><span>Simple Ruby interface to CouchDB</span></div>
|
40
|
-
|
41
|
-
</div><!-- #header -->
|
42
|
-
|
43
|
-
</div><!-- #header-container -->
|
44
|
-
|
45
|
-
|
46
|
-
<div id="container">
|
47
|
-
|
48
|
-
|
49
|
-
<div id="content" class="hfeed content">
|
50
|
-
|
51
|
-
<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail"><span class="trail-before"><span class="breadcrumb-title">Browse:</span></span> <a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/" title="Leanback" rel="home" class="trail-begin">Home</a> <span class="sep">/</span> <span class="trail-end">Find documents by key</span></div></div>
|
52
|
-
|
53
|
-
<div id="post-26" class="hentry page publish post-1 odd author-admin">
|
54
|
-
|
55
|
-
<h1 class="page-title entry-title"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/" title="Find documents by key" rel="bookmark">Find documents by key</a></h1>
|
56
|
-
<div class="entry-content">
|
57
|
-
<p>First we login to CouchDB and generate the auth_session token for making requests.</p>
|
58
|
-
|
59
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">hash = Couchdb.<span style="color:#9900CC;">login</span><span style="color:#006600; font-weight:bold;">(</span>username = <span style="color:#996600;">'samson'</span>,password =<span style="color:#996600;">'sam123'</span><span style="color:#006600; font-weight:bold;">)</span>
|
60
|
-
auth_session = hash<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"AuthSession"</span><span style="color:#006600; font-weight:bold;">]</span></pre></div></div>
|
61
|
-
|
62
|
-
<p>To find documents by email key (example: to find all contacts with email = ‘nancy@mail.com’)</p>
|
63
|
-
|
64
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'nancy@mail.com'</span><span style="color:#006600; font-weight:bold;">}</span> , auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
65
|
-
|
66
|
-
<span style="color:#008000; font-style:italic;"># => [{"_id"=>"Nancy", "_rev"=>"1-d15a83d2a23b495c19df2595b636ecc8", "firstname"=>"Nancy", "lastname"=>"Lee",</span>
|
67
|
-
<span style="color:#008000; font-style:italic;"># "phone"=>"347-808-3734", "email"=>"nancy@mail.com", "gender"=>"female"}]</span></pre></div></div>
|
68
|
-
|
69
|
-
<p>To find all contacts with lastname = ‘Smith’</p>
|
70
|
-
|
71
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:lastname</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'Smith'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
72
|
-
|
73
|
-
<span style="color:#008000; font-style:italic;"># => [{"_id"=>"john", "_rev"=>"5-642689e0a50843d6fa508159a01b4fd4", "firstname"=>"John", "lastname"=>"Smith",</span>
|
74
|
-
<span style="color:#008000; font-style:italic;"># "email"=>"john@mail.com", "gender"=>"male"}]</span></pre></div></div>
|
75
|
-
|
76
|
-
<p>To find all female contacts</p>
|
77
|
-
|
78
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
79
|
-
|
80
|
-
<span style="color:#008000; font-style:italic;"># => [{"_id"=>"Nancy", "_rev"=>"1-d15a83d2a23b495c19df2595b636ecc8", "firstname"=>"Nancy", "lastname"=>"Lee",</span>
|
81
|
-
<span style="color:#008000; font-style:italic;"># "phone"=>"347-808-3734", "email"=>"nancy@mail.com", "gender"=>"female"}]</span></pre></div></div>
|
82
|
-
|
83
|
-
<p>If you are running an admin party (i.e you have no admins in CouchDB), simply use the same methods, with no auth_session parameter.</p>
|
84
|
-
|
85
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span> <span style="color:#ff3333; font-weight:bold;">:database</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
86
|
-
|
87
|
-
<p><strong>Options</strong><br />
|
88
|
-
A set of options can be used to manipulate the results.</p>
|
89
|
-
<p><strong>limits</strong><br />
|
90
|
-
To limit the results. Example to return the first 20 female contacts:</p>
|
91
|
-
|
92
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:limit <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
93
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
94
|
-
|
95
|
-
<p><strong>skip</strong><br />
|
96
|
-
To skip the first 10 female contacts and return 20:</p>
|
97
|
-
|
98
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:skip <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">10</span>,:limit <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
99
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
100
|
-
|
101
|
-
<p>Note that the skip option is considered a relatively expensive CouchDB operations because the rows are still processed and skipped.</p>
|
102
|
-
<p>To skip the first 20 female contacts and return all remaining contacts:</p>
|
103
|
-
|
104
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:skip <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
105
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
106
|
-
|
107
|
-
<p><strong>descending</strong><br />
|
108
|
-
Couchdb returns results in ascending order by default, to change it to descending order:</p>
|
109
|
-
|
110
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:descending <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">}</span>
|
111
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
112
|
-
|
113
|
-
<p><strong>startkey & endkey</strong><br />
|
114
|
-
To return the results within a range. For example in an employee database, to return all employees with the salary range 53000 to 99000</p>
|
115
|
-
|
116
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:startkey <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"53000"</span>, <span style="color:#ff3333; font-weight:bold;">:endkey</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"99000"</span><span style="color:#006600; font-weight:bold;">}</span>
|
117
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'employees'</span>, <span style="color:#ff3333; font-weight:bold;">:salary</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
118
|
-
|
119
|
-
<p>To return the first 20 employees with salary between 53000 and 99000.</p>
|
120
|
-
|
121
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:startkey <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"53000"</span>, <span style="color:#ff3333; font-weight:bold;">:endkey</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"99000"</span>,:limit <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#006666;">20</span><span style="color:#006600; font-weight:bold;">}</span>
|
122
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'employees'</span>, <span style="color:#ff3333; font-weight:bold;">:salary</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
123
|
-
|
124
|
-
<p>To return all employees with salary 99000 or less:</p>
|
125
|
-
|
126
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">options = <span style="color:#006600; font-weight:bold;">{</span>:endkey <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">"99000"</span><span style="color:#006600; font-weight:bold;">}</span>
|
127
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'employees'</span>, <span style="color:#ff3333; font-weight:bold;">:salary</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session, options<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
128
|
-
|
129
|
-
<p><strong>How it works</strong><br />
|
130
|
-
The method</p>
|
131
|
-
|
132
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'nancy@mail.com'</span><span style="color:#006600; font-weight:bold;">}</span>, auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
133
|
-
|
134
|
-
<p>sends a</p>
|
135
|
-
|
136
|
-
<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">GET http://127.0.0.1:5984/contacts/_design/email_finder/_view/find_by_email?key="nancy@mail.com"</pre></div></div>
|
137
|
-
|
138
|
-
<p>This returns all contacts with email = ‘nancy@mail.com’. Leanback will parse the native JSON results to return only the data values. If the design_document (_design/email_finder) and the view (find_by_email) doesn’t exist, Leanback will create it in the database. See the source for the generated design_document;</p>
|
139
|
-
|
140
|
-
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">{</span>
|
141
|
-
<span style="color: #3366CC;">"_id"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"_design/email_finder"</span><span style="color: #339933;">,</span>
|
142
|
-
<span style="color: #3366CC;">"_rev"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"7-da7f3c0bf183f4a36a82013bd0ea6537"</span><span style="color: #339933;">,</span>
|
143
|
-
<span style="color: #3366CC;">"language"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"javascript"</span><span style="color: #339933;">,</span>
|
144
|
-
<span style="color: #3366CC;">"views"</span><span style="color: #339933;">:</span> <span style="color: #009900;">{</span>
|
145
|
-
<span style="color: #3366CC;">"find_by_email"</span><span style="color: #339933;">:</span> <span style="color: #009900;">{</span>
|
146
|
-
<span style="color: #3366CC;">"map"</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">"function(doc){
|
147
|
-
if(doc.email)
|
148
|
-
emit(doc.email,doc);
|
149
|
-
}"</span>
|
150
|
-
<span style="color: #009900;">}</span>
|
151
|
-
<span style="color: #009900;">}</span>
|
152
|
-
<span style="color: #009900;">}</span></pre></div></div>
|
153
|
-
|
154
|
-
<p>If you ran</p>
|
155
|
-
|
156
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:lastname</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'Smith'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
157
|
-
Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'female'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span></pre></div></div>
|
158
|
-
|
159
|
-
<p>you will notice the following design_documents have been added to the database</p>
|
160
|
-
|
161
|
-
<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">_design/lastname_finder
|
162
|
-
_design/gender_finder</pre></div></div>
|
163
|
-
|
164
|
-
<p><strong>Usage</strong><br />
|
165
|
-
You can do</p>
|
166
|
-
|
167
|
-
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> docs = Couchdb.<span style="color:#9900CC;">find_by</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#006600; font-weight:bold;">{</span>:database <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'contacts'</span>, <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=></span> <span style="color:#996600;">'nancy@mail.com'</span><span style="color:#006600; font-weight:bold;">}</span>,auth_session<span style="color:#006600; font-weight:bold;">)</span>
|
168
|
-
docs.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>d<span style="color:#006600; font-weight:bold;">|</span>
|
169
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"_rev"</span><span style="color:#006600; font-weight:bold;">]</span>
|
170
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"_id"</span><span style="color:#006600; font-weight:bold;">]</span>
|
171
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"firstname"</span><span style="color:#006600; font-weight:bold;">]</span>
|
172
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"lastname"</span><span style="color:#006600; font-weight:bold;">]</span>
|
173
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"email"</span><span style="color:#006600; font-weight:bold;">]</span>
|
174
|
-
<span style="color:#CC0066; font-weight:bold;">puts</span> d<span style="color:#006600; font-weight:bold;">[</span><span style="color:#996600;">"phone"</span><span style="color:#006600; font-weight:bold;">]</span>
|
175
|
-
<span style="color:#9966CC; font-weight:bold;">end</span>
|
176
|
-
|
177
|
-
<span style="color:#008000; font-style:italic;"># => rev1-d15a83d2a23b495c19df2595b636ecc8</span>
|
178
|
-
<span style="color:#008000; font-style:italic;"># Nancy</span>
|
179
|
-
<span style="color:#008000; font-style:italic;"># Nancy</span>
|
180
|
-
<span style="color:#008000; font-style:italic;"># Lee</span>
|
181
|
-
<span style="color:#008000; font-style:italic;"># nancy@mail.com</span>
|
182
|
-
<span style="color:#008000; font-style:italic;"># 347-808-3734</span></pre></div></div>
|
183
|
-
|
184
|
-
</div><!-- .entry-content -->
|
185
|
-
|
186
|
-
|
187
|
-
</div><!-- .hentry -->
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
</div><!-- .content .hfeed -->
|
196
|
-
|
197
|
-
|
198
|
-
<div id="primary" class="sidebar aside">
|
199
|
-
|
200
|
-
|
201
|
-
<div id="hybrid-nav-menu-3" class="widget nav-menu widget-nav-menu"><div class="widget-wrap widget-inside"><h3 class="widget-title">Leanback</h3><div class="menu-sidebar-container"><ul id="menu-sidebar" class="nav-menu"><li id="menu-item-13" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-13"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/">Leanback</a><ul class="sub-menu"><li id="menu-item-14" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-14"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/leanback/installation/">Install</a></li><li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/basic-couchdb-operations/">Basic CouchDB Operations</a></li><li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-26 current_page_item menu-item-41"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-documents-by-key/">Find documents by key</a></li><li id="menu-item-167" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-167"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/find-document-by-multiple-keys/">Find document by multiple Keys</a></li><li id="menu-item-140" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-140"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-documents-by-key/">Count documents by key</a></li><li id="menu-item-175" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-175"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/count-by-multiple-documents/">Count documents by multiple keys</a></li><li id="menu-item-45" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-45"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/design-documents-and-permanent-views/">Working with CouchDB views</a></li><li id="menu-item-67" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-67"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/error-handling/">Error handling</a></li><li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-96"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-configuration/">CouchDB Configuration</a></li><li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/couchdb-security/">CouchDB Security</a></li><li id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-105"><a href="http://www.whisperservers.com/leanback/wp-content/plugins/really-static/static/setting-the-bind_address-port/">CouchDB Bind_Address & Port</a></li></ul></li><li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-142"><a href="https://github.com/obi-a/leanback/blob/master/Changelog.rdoc">Changes</a></li><li id="menu-item-78" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-78"><a href="https://github.com/obi-a/leanback">Source Code</a></li></ul></div></div></div>
|
202
|
-
|
203
|
-
</div><!-- #primary .aside -->
|
204
|
-
|
205
|
-
|
206
|
-
</div><!-- #container -->
|
207
|
-
|
208
|
-
<div id="footer-container">
|
209
|
-
|
210
|
-
|
211
|
-
<div id="footer">
|
212
|
-
|
213
|
-
<div class="footer-insert"><p class="copyright">Copyright © 2013 <a href="http://obi-akubue.org">obi-akubue.org</a>.</p></div>
|
214
|
-
</div><!-- #footer -->
|
215
|
-
|
216
|
-
|
217
|
-
</div><!-- #footer-container -->
|
218
|
-
|
219
|
-
</div><!-- #body-container -->
|
220
|
-
|
221
|
-
|
222
|
-
<script type="text/javascript">
|
223
|
-
|
224
|
-
var _gaq = _gaq || [];
|
225
|
-
_gaq.push(['_setAccount', 'UA-20190925-6']);
|
226
|
-
_gaq.push(['_trackPageview']);
|
227
|
-
|
228
|
-
(function() {
|
229
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
230
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
231
|
-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
|
232
|
-
})();
|
233
|
-
</script>
|
234
|
-
|
235
|
-
<a style='color:transparent;position:absolute;left:-99999px;z-index:-99999' href='http://www.wpdownloadmanager.com/' title='Premium Wordpress Plugin download manager'>Premium Wordpress Plugin</a>
|
236
|
-
<script type='text/javascript' src='http://www.whisperservers.com/leanback/wp-content/themes/hybrid/library/js/drop-downs.js?ver=20110705'></script>
|
237
|
-
|
238
|
-
</body>
|
239
|
-
</html>
|
240
|
-
<!-- Dynamic page generated in 0.547 seconds. -->
|
241
|
-
<!-- Cached page generated by WP-Super-Cache on 2013-06-09 16:30:52 -->
|
242
|
-
|
243
|
-
<!-- super cache -->
|