Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The following page has been changed by mdornseif:
http://wiki.apache.org/couchdb/View_Snippets
The comment on the change is:
Addes Pseudo-SQL equivalents and a curl example
------------------------------------------------------------------------------
}
}}}
+ In SQL this would be something like {{{SELECT if FROM table WHERE attachment IS NOT NULL}}}.
+
+
== Count documents which and without an attatchment ==
+
+ Call this with ''group=true'' or you only get the combined number of docoments witch and
without attachments.
{{{
map: function(doc) {
@@ -30, +35 @@
}
}}}
+ Using curl you can call it like this:
+
+ {{{
+ curl -s -i -X POST -H 'Content-Type: application/json'
+ -d '{"map": "function(doc){if(doc._attachments) {emit(\"with\",1);} else {emit(\"without\",1);}}",
+ "reduce": "function(keys, values) {return sum(values);}"}'
+ 'http://localhost:5984/somedb/_temp_view?group=true'
+ }}}
+
+ In SQL this would be something along the lines of {{{SELECT num_attachments FROM table GROUP
BY num_attachments}}} (but this would give extra output for rows containing more than one
attachment).
+
|