Skip to content
Browse files

MB-7126 Add "if guards" in sample data view functions

gamesim-sample/design_docs/players.json:leaderboard/map

  function (doc, meta) {
    if (doc.jsonType == "player" && doc.experience) {
      emit(doc.experience, null);
    }
  }

beer-sample/design_docs/beer.json:brewery_beers/map

  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: Ibb6039580ec1d2a4f232e4302e57baeaeb8530e6
Reviewed-on: http://review.couchbase.org/22364
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
1 parent 544688d commit c59551adf11860963c1bba028adf33529a4a4d4a @avsej avsej committed with steveyen Nov 8, 2012
View
BIN beer-sample.zip
Binary file not shown.
View
BIN gamesim-sample.zip 100755 → 100644
Binary file not shown.
View
2 gamesim-sample/design_docs/players.json
@@ -3,7 +3,7 @@
"language": "javascript",
"views": {
"leaderboard": {
- "map": "function (doc, meta) {\n if (doc.jsonType == \"player\") {\n emit(doc.experience, null);\n }\n}"
+ "map": "function (doc, meta) {\n if (doc.jsonType == \"player\" && doc.experience) {\n emit(doc.experience, null);\n }\n}"
},
"playerlist": {
"map": "function (doc, meta) {\n if (doc.jsonType == \"player\") {\n emit(meta.id, null);\n }\n}"

0 comments on commit c59551a

Please sign in to comment.
Something went wrong with that request. Please try again.