Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 2 commits into from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 31, 2012
  1. Update backbone-couchdb.js

    Josh Nisenson authored
Commits on Feb 1, 2012
  1. Update backbone-couchdb.coffee

    Josh Nisenson authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 3 deletions.
  1. +1 −1  backbone-couchdb.coffee
  2. +1 −2  backbone-couchdb.js
2  backbone-couchdb.coffee
View
@@ -65,7 +65,7 @@ Backbone.couch_connector = con =
success : (data) =>
_temp = []
for doc in data.rows
- _temp.push doc.value
+ if doc.value then _temp.push doc.value else _temp.push doc.doc
opts.success _temp
opts.complete()
error : ->
3  backbone-couchdb.js
View
@@ -1,4 +1,3 @@
-
/*
(c) 2011 Jan Monschke
v1.1
@@ -73,7 +72,7 @@ backbone-couchdb.js is licensed under the MIT license.
_ref = data.rows;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
doc = _ref[_i];
- _temp.push(doc.value);
+ (doc.value) ? _temp.push(doc.value) : _temp.push(doc.doc);
}
opts.success(_temp);
return opts.complete();
Something went wrong with that request. Please try again.