Permalink
Browse files

Check brewery_id presence in "brewery_beers" mapper

Now it will look like:

  function(doc, meta) {
    switch(doc.type) {
    case "brewery":
      emit([meta.id]);
      break;
    case "beer":
      if (doc.brewery_id) {
        emit([doc.brewery_id, meta.id]);
      }
      break;
    }
  }

Change-Id: Id945e5c85d7f05d5f316eebc65ea4e8fe6920b25
  • Loading branch information...
1 parent 0477f35 commit 1c566089a582ac8a6c36f155e7885818f6dadbb2 @avsej committed Nov 8, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 design_docs/beer.json
View
@@ -3,7 +3,7 @@
"language": "javascript",
"views": {
"brewery_beers": {
- "map": "function(doc, meta) {\n switch(doc.type) {\n case \"brewery\":\n emit([meta.id]);\n break;\n case \"beer\":\n emit([doc.brewery_id, meta.id]);\n break;\n }\n}"
+ "map": "function(doc, meta) {\n switch(doc.type) {\n case \"brewery\":\n emit([meta.id]);\n break;\n case \"beer\":\n if (doc.brewery_id) {\n emit([doc.brewery_id, meta.id]);\n }\n break;\n }\n}\n"
},
"by_location": {
"map": "function (doc, meta) {\n if (doc.country, doc.state, doc.city) {\n emit([doc.country, doc.state, doc.city], 1);\n } else if (doc.country, doc.state) {\n emit([doc.country, doc.state], 1);\n } else if (doc.country) {\n emit([doc.country], 1);\n }\n}",

0 comments on commit 1c56608

Please sign in to comment.