Skip to content
This repository

Fix for "include_docs : true" when the view emits a null value #35

Merged
merged 2 commits into from about 2 years ago

2 participants

Josh Nisenson Jan Monschke
Josh Nisenson

This fix handles the case where include_docs is true and the view emits only the key and null. When the view value is null we check to see if the doc exists in the returned data (as it will when include_docs is true)

Example for a couchapp view with a complex key:
"by_test_type_date" : {
"map": "function (doc) { emit([doc.test_type, doc.created_at], null);}"
}

Jan Monschke
Owner

Looks good, can you provide the CoffeeScript source as well and recompile it then?
This is the part of the CS doc for conditionals: http://coffeescript.org/#conditionals

Josh Nisenson

Here is the pull request that includes the .coffee fix as well using:

if doc.value then _temp.push doc.value else _temp.push doc.doc

Jan Monschke
Owner

That was quick :) Thx!

Jan Monschke janmonschke merged commit de45b6b into from February 01, 2012
Jan Monschke janmonschke closed this February 01, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jan 31, 2012
Update backbone-couchdb.js f0d53c4
Feb 01, 2012
Update backbone-couchdb.coffee fd82457
This page is out of date. Refresh to see the latest.
2  backbone-couchdb.coffee
@@ -65,7 +65,7 @@ Backbone.couch_connector = con =
65 65
       success : (data) =>
66 66
         _temp = []
67 67
         for doc in data.rows
68  
-          _temp.push doc.value
  68
+          if doc.value then _temp.push doc.value else _temp.push doc.doc
69 69
         opts.success _temp
70 70
         opts.complete()
71 71
       error : ->
3  backbone-couchdb.js
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 /*
3 2
 (c) 2011 Jan Monschke
4 3
 v1.1
@@ -73,7 +72,7 @@ backbone-couchdb.js is licensed under the MIT license.
73 72
           _ref = data.rows;
74 73
           for (_i = 0, _len = _ref.length; _i < _len; _i++) {
75 74
             doc = _ref[_i];
76  
-            _temp.push(doc.value);
  75
+            (doc.value) ? _temp.push(doc.value) : _temp.push(doc.doc);
77 76
           }
78 77
           opts.success(_temp);
79 78
           return opts.complete();
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.