CouchConf-Berlin-Advanced-document-design

669 views
573 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
669
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • CouchConf-Berlin-Advanced-document-design

    1. 1. Advanced Document DesignVolker @vmische
    2. 2. SCHEMA-LESS DATABASE 2
    3. 3. SCHEMA-LESS DATABASEDocument structure comes but at the query level, not at the 2
    4. 4. SCHEMA-LESS DATABASEDocument structure comes but at the query level, not at theAd hoc data no need to define schema before 2
    5. 5. SCHEMA-LESS DATABASEDocument structure comes but at the query level, not at theAd hoc data no need to define schema beforebut you can limit the chaos of schema-less 2
    6. 6. “SCHEMA” ENFORCEMENT 3
    7. 7. VALIDATE_DOC_UPD 4
    8. 8. VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) { ... } 4
    9. 9. VALIDATE_DOC_UPD“validate_doc_update”: incoming JSON “function(newDoc, oldDoc, userCtx, secObj) { ... } 4
    10. 10. VALIDATE_DOC_UPD“validate_doc_update”: incoming JSON “function(newDoc, oldDoc, userCtx, secObj) { existing document (loaded from ... } 4
    11. 11. VALIDATE_DOC_UPD“validate_doc_update”: current user’s information from incoming JSON “function(newDoc, oldDoc, userCtx, secObj) { existing document (loaded from ... } 4
    12. 12. VALIDATE_DOC_UPD“validate_doc_update”: current user’s information from incoming JSON “function(newDoc, oldDoc, userCtx, secObj) { existing document (loaded from _security settings for ... } 4
    13. 13. VALIDATE_DOC_UPDATE 5
    14. 14. VALIDATE_DOC_UPDATEOptionally-enforced schema 5
    15. 15. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsave 5
    16. 16. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsaveCannot modify newDoc 5
    17. 17. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsaveCannot modify newDocCan enforce field types, values 5
    18. 18. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsaveCannot modify newDocCan enforce field types, valuesCan prevent docs or fields from being updatedagain 5
    19. 19. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsaveCannot modify newDocCan enforce field types, valuesCan prevent docs or fields from being updatedagain(created_at, user) 5
    20. 20. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsaveCannot modify newDocCan enforce field types, valuesCan prevent docs or fields from being updatedagain(created_at, user)Runs every time a document isupdated 5
    21. 21. VALIDATE_DOC_UPDATEOptionally-enforced schemaThrow ‘forbidden’ or ‘unauthorized’ to preventsaveCannot modify newDocCan enforce field types, valuesCan prevent docs or fields from being updatedagain(created_at, user)Runs every time a document isupdated Even during replication and bulkoperations 5
    22. 22. “VALIDATE_DOC_UPD 6
    23. 23. “VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) { if(oldDoc && toJSON(oldDoc[field]) != toJSON(newDoc[field])) { throw({forbidden:”Field can’t be changed: “ + field}); } if(!newDoc.address) { throw({forbidden: “Document must have an address”}); } } 6
    24. 24. “VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) { oldDoc if(oldDoc && toJSON(oldDoc[field]) != toJSON(newDoc[field])) { throw({forbidden:”Field can’t be changed: “ + field}); } if(!newDoc.address) { throw({forbidden: “Document must have an address”}); } } 6
    25. 25. “VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) { oldDoc has the if(oldDoc && toJSON(oldDoc[field]) != toJSON(newDoc[field])) { throw({forbidden:”Field can’t be changed: “ + field}); } if(!newDoc.address) { throw({forbidden: “Document must have an address”}); } } 6
    26. 26. “VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) {newDoc’s it’s different than if(oldDoc && toJSON(oldDoc[field]) != toJSON(newDoc[field])) { throw({forbidden:”Field can’t be changed: “ + field}); } if(!newDoc.address) { throw({forbidden: “Document must have an address”}); } } 6
    27. 27. “VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) { if(oldDoc && toJSON(oldDoc[field]) != throw either forbidden or toJSON(newDoc[field])) { throw({forbidden:”Field can’t be changed: “ + field}); } if(!newDoc.address) { throw({forbidden: “Document must have an address”}); } } 6
    28. 28. “VALIDATE_DOC_UPD“validate_doc_update”: “function(newDoc, oldDoc, userCtx, secObj) { if(oldDoc && toJSON(oldDoc[field]) != toJSON(newDoc[field])) { throw({forbidden:”Fieldan address changed: “ + field}); newDoc doesn’t have can’t be } if(!newDoc.address) { throw({forbidden: “Document must have an address”}); } } 6
    29. 29. _UPDATE HANDLERS 7
    30. 30. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpoints 7
    31. 31. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpointsPUT /{db}/_design/{app}/_update/{function}/{_id} 7
    32. 32. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpointsPUT /{db}/_design/{app}/_update/{function}/{_id} /{db}/_design/{app}/_update/POST{function} 7
    33. 33. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpointsPUT /{db}/_design/{app}/_update/{function}/{_id} /{db}/_design/{app}/_update/POST{function}Content can be of any Content-Type/mime-type XML, KML ( committed doc must be JSON) 7
    34. 34. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpointsPUT /{db}/_design/{app}/_update/{function}/{_id} /{db}/_design/{app}/_update/POST{function}Content can be of any Content-Type/mime-type XML, KML ( committed doc must be JSON)Can be used for field-atomic updates 7
    35. 35. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpointsPUT /{db}/_design/{app}/_update/{function}/{_id} /{db}/_design/{app}/_update/POST{function}Content can be of any Content-Type/mime-type XML, KML ( committed doc must be JSON)Can be used for field-atomic updatesuserCtx object holds authenticated user data 7
    36. 36. _UPDATE HANDLERSAugment Couchbase’s API with your ownendpointsPUT /{db}/_design/{app}/_update/{function}/{_id} /{db}/_design/{app}/_update/POST{function}Content can be of any Content-Type/mime-type XML, KML ( committed doc must be JSON)Can be used for field-atomic updatesuserCtx object holds authenticated user dataCAUTION: replication and bulkoperations don’t use this,so don’t depend on it for yoursolesource of schema enforcement 7
    37. 37. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    38. 38. _UPDATE HANDLERSno existing doc on disk for the requested “id” ... it’s a function(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s* $/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized]; } 8
    39. 39. _UPDATE HANDLERSfunction(doc, req) { there’s an “id” in the if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    40. 40. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { get the document from the request doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    41. 41. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); assign it the id from the doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    42. 42. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } process every property in the } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    43. 43. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } trim leading and trailing blanks from property for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    44. 44. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/,from property name and trim leading and trailing blanks ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized];} 8
    45. 45. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc will be doc[newProp] = v; } return [doc, Sanitized];} 8
    46. 46. _UPDATE HANDLERSfunction(doc, req) { if (!doc) { if (req.id) { doc = JSON.parse(req.body); doc._id = req.id; } } for(prop in doc) { var v = doc[prop].replace(/^s*/, ).replace(/s*$/, ) var newProp = prop.replace(/^s*/, ).replace(/s*$/, ).replace(/ /g,"_").toLowerCase(); delete doc[prop]; doc[newProp] = v; } return [doc, Sanitized]; message is returned to the caller} 8
    47. 47. QUERYING 9
    48. 48. VIEW COLLATION 10
    49. 49. VIEW COLLATIONMapReduce emits keys and values 10
    50. 50. VIEW COLLATIONMapReduce emits keys and valuesDictionary sorting of those keys can providestructure Collation Algorithm Unicode 10
    51. 51. VIEW COLLATIONMapReduce emits keys and valuesDictionary sorting of those keys can providestructure Collation Algorithm UnicodeCan be used to group relateddocuments 10
    52. 52. VIEW COLLATIONMapReduce emits keys and valuesDictionary sorting of those keys can providestructure Collation Algorithm UnicodeCan be used to group relateddocuments Emit related data + ordering component {“key”: [doc.took_office], “value”: doc.name} {“key”: [doc.year, 1], “value”: doc.event} 10
    53. 53. VIEW COLLATION"views": { "president_events": "function(doc) { if (doc.type == "president") { emit([doc.took_office], doc.name); } else if (doc.type == "event") { emit([doc.year, 0], doc.event); } }} 11
    54. 54. VIEW COLLATIONcan be used to group relateddocuments"views": { "president_events": "function(doc) { if (doc.type == "president") { emit([doc.took_office], doc.name); } else if (doc.type == "event") { emit([doc.year, 0], doc.event); } }} 11
    55. 55. VIEW COLLATIONcan be used to group relateddocuments"views": { "president_events": "function(doc) { e.g., emit([1981], “Ronald if (doc.type == "president") { emit([doc.took_office], doc.name); } else if (doc.type == "event") { emit([doc.year, 0], doc.event); } }} 11
    56. 56. VIEW COLLATION can be used to group related documents"views": { "president_events": "function(doc) { if (doc.type == "president") { emit([doc.took_office], on, becoming e.g., emit([1981, 0], "MTV signs doc.name); cable network dedicated to airing the first 24-hour } else if (doc.type == "event") { emit([doc.year, 0], doc.event); } }} 11
    57. 57. VIEW COLLATION can be used to group related documents"views": { "president_events": "function(doc) { if (doc.type == "president") { emit([doc.took_office], doc.name); } else if (doc.type == "event") { emit([doc.year, 0], doc.event); e.g., emit([1981, 0], "The Space Shuttle Columbia } is launched, marking America"s first return to space }} 11
    58. 58. VIEW COLLATIONcan be used to group relateddocuments"views": { "president_events": "function(doc) { if (doc.type == "president") { emit([doc.took_office], doc.name); } else if (doc.type == "event") { emit([doc.year, 0], doc.event); } }} 11
    59. 59. RESULT OF |[1980, 0], "Mount St. Helens eruption in Washingtonkills 57")[1980, 0], "John Lennon Assassinated")[1981], “Ronald Reagan”[1981, 0], "MTV signs on, becoming the first 24-hour cable network dedicated to airing musicvideos.")[1981, 0], "The Space Shuttle Columbia is launched,marking America"s first return to space since 1975") | 12
    60. 60. UNICODE COLLATION 13
    61. 61. UNICODE COLLATIONIt’s not ASCII order! All symbols sort before numbers and letters (even the "high" symbols like tilde, 0x7e) 13
    62. 62. UNICODE COLLATIONIt’s not ASCII order! All symbols sort before numbers and letters (even the "high" symbols like tilde, sequences of letters are compared Differing 0x7e) without regard to case, so a < aa but also A < aa and a < AA 13
    63. 63. UNICODE COLLATIONIt’s not ASCII order! All symbols sort before numbers and letters (even the "high" symbols like tilde, sequences of letters are compared Differing 0x7e) without regard to case, so a < aa but also A < aa and a < AA Identical sequences of letters are compared with regard to case, with lowercase before uppercase, so a < A 13
    64. 64. UNICODE COLLATIONIt’s not ASCII order! All symbols sort before numbers and letters (even the "high" symbols like tilde, sequences of letters are compared Differing 0x7e) without regard to case, so a < aa but also A < aa and a < AA Identical sequences of letters are compared with regard to case, with lowercase before uppercase, so a < ALike this...`^_-,;:!?."()[]{}@*/&#%+<=>|~$0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ 13
    65. 65. VIEW COLLATION 14
    66. 66. VIEW COLLATION?include_docs=tru “joining” MapReduce results super handy fore 14
    67. 67. VIEW COLLATION?include_docs=tru “joining” MapReduce results super handy fore can help you “accept” using multiple, smaller docs 14
    68. 68. VIEW COLLATION?include_docs=tru “joining” MapReduce results super handy fore can help you “accept” using multiple, smaller docs documents by their “_id” in aReference related“parent” document 14
    69. 69. VIEW COLLATION?include_docs=tru “joining” MapReduce results super handy fore can help you “accept” using multiple, smaller docs documents by their “_id” in aReference related“parent” documentEmit the referenced “_id” in the value ofan{“value”: {“_id”: “referenced- emit id”}} 14
    70. 70. VIEW COLLATION?include_docs=tru “joining” MapReduce results super handy fore can help you “accept” using multiple, smaller docs documents by their “_id” in aReference related“parent” documentEmit the referenced “_id” in the value ofan{“value”: {“_id”: “referenced- emit id”}} key is added to thea “doc”resultsexample of this comingshortly... 14
    71. 71. MORE TOOLS output functions 15
    72. 72. MORE TOOLS output functions_show/{show_function_name}/{doc_id} runs a single doc through an additional “display” function 15
    73. 73. MORE TOOLS output functions_show/{show_function_name}/{doc_id} runs a single doc through an additional “display” function_list/{list_function_name}/{view_name} same as _show, but for map/reduce results 15
    74. 74. _LIST 16
    75. 75. _LIST/{db}/_design/{app}/_list/{list_fun}/{view_fun} runs the results of {view_fun} through {list_fun} 16
    76. 76. _LIST/{db}/_design/{app}/_list/{list_fun}/{view_fun} runs the results of {view_fun} through {list_fun} can return any Content-Type 16
    77. 77. _LIST/{db}/_design/{app}/_list/{list_fun}/{view_fun} runs the results of {view_fun} through {list_fun} can return any Content-Type great for combining a chunk of collated results 16
    78. 78. _LIST/{db}/_design/{app}/_list/{list_fun}/{view_fun} runs the results of {view_fun} through {list_fun} can return any Content-Type great for combining a chunk of collated results use startkey/endkey to limit map output 16
    79. 79. BASIC LIST"lists": { "foo": "function(head, req) { { var row; start({ "headers": { "Content-Type": "text/ html" } }); while(row = getRow()) { send(row.value); } }} 17
    80. 80. BASIC LIST"lists": { "foo": "function(head, req) { { begins HTTP output var row; start({ "headers": { "Content-Type": "text/ html" } }); while(row = getRow()) { send(row.value); } }} 17
    81. 81. BASIC LIST"lists": { "foo": "function(head, req) { { var row; start({ "headers": { "Content-Type": "text/ html" } retrieves a row from the MapReduce }); while(row = getRow()) { send(row.value); } }} 17
    82. 82. BASIC LIST"lists": { "foo": "function(head, req) { { var row; start({ "headers": { "Content-Type": "text/ html" } }); while(row = getRow()) { send(row.value); } sends line into HTTP }} 17
    83. 83. BASIC LIST"lists": { "foo": "function(head, req) { { var row; start({ "headers": { "Content-Type": "text/ html" } }); while(row = getRow()) { send(row.value); } }} 17
    84. 84. PUTTING IT ALL 18
    85. 85. 19
    86. 86. 19
    87. 87. BLUEINK page document page items page area page area content item “Welcome” content item “Logging In” content item“Benjamin Young” 20
    88. 88. BLUEINK 21
    89. 89. BLUEINK“page” docs reference content and templatedocs 21
    90. 90. BLUEINK“page” docs reference content and templatedocsMapReduce aggregates... general page and page layout data 21
    91. 91. BLUEINK“page” docs reference content and templatedocsMapReduce aggregates... general page and page layout data site wide settings 21
    92. 92. BLUEINK“page” docs reference content and templatedocsMapReduce aggregates... general page and page layout data site wide settings the chosen template 21
    93. 93. BLUEINK“page” docs reference content and templatedocsMapReduce aggregates... general page and page layout data site wide settings the chosen template and the page’s content items 21
    94. 94. BLUEINK“page” docs reference content and templatedocsMapReduce aggregates... general page and page layout data site wide settings the chosen template and the page’s content itemsa _list function... applies the template 21
    95. 95. BLUEINK“page” docs reference content and templatedocsMapReduce aggregates... general page and page layout data site wide settings the chosen template and the page’s content itemsa _list function... applies the template and builds the final page 21
    96. 96. BLUEINK 22
    97. 97. BLUEINKcontent item docs (“text”, “blogs”, “calendars”,etc.) Couchbase-generated UUIDs use 22
    98. 98. BLUEINKcontent item docs (“text”, “blogs”, “calendars”,etc.) Couchbase-generated UUIDs use hold content separately from page docs 22
    99. 99. BLUEINKcontent item docs (“text”, “blogs”, “calendars”,etc.) Couchbase-generated UUIDs use hold content separately from page docs allows independent updates 22
    100. 100. BLUEINKcontent item docs (“text”, “blogs”, “calendars”,etc.) Couchbase-generated UUIDs use hold content separately from page docs allows independent updates far fewer conflicts if not embedded in page 22
    101. 101. BLUEINKcontent item docs (“text”, “blogs”, “calendars”,etc.) Couchbase-generated UUIDs use hold content separately from page docs allows independent updates far fewer conflicts if not embedded in page content can be shared/reused among pages 22
    102. 102. BLUEINK 23
    103. 103. BLUEINKsite and template docs use user-defined document IDs 23
    104. 104. BLUEINKsite and template docs use user-defined document IDs site - contains general site info (copyright, title) 23
    105. 105. BLUEINKsite and template docs use user-defined document IDs site - contains general site info (copyright, title) template - raw Mustache template for page rendering 23
    106. 106. BLUEINKsite and template docs use user-defined document IDs site - contains general site info (copyright, title) template - raw Mustache template for page rendering as HTML; all in one GET sent back 23
    107. 107. PAGE ITEMS{[[ {"_id": "8dd982de76e8b5959e10e6d4360067ce", "display_title": true} {"_id": "13a54b6e52123745cced243d620003e0", "display_title": false},],[ {"_id": "90cb972de2a11045be18a3a88c001bad", "display_title": true}]]} 24
    108. 108. PAGE ITEMS{[ page document[ page items {"_id": "8dd982de76e8b5959e10e6d4360067ce", "display_title": true} page area page area {"_id": "13a54b6e52123745cced243d620003e0", "display_title": false}, content item], “Welcome” content item[ “Logging In” content item {"_id": "90cb972de2a11045be18a3a88c001bad", "display_title": true} “Benjamin Young”]]} 24
    109. 109. PAGE ITEMS{[[ {"_id": "8dd982de76e8b5959e10e6d4360067ce", "display_title": true} {"_id": "13a54b6e52123745cced243d620003e0", "display_title": false},],[ {"_id": "90cb972de2a11045be18a3a88c001bad", "display_title": true}]]} 24
    110. 110. “HTML” ITEM DOC{ "_id": "8dd982de76e8b5959e10e6d43600615d", "_rev": "174-aa7546e6308324d4b3ad84469fcbd773", "type": "html", "created": "2008-06-18 15:03:45", "updated": "2009-08-08 13:28:58", "title": "Welcome", "content": "<p>The <a href="http://blueinkcms.com/"><strong>BlueInk Content Management System (CMS)</strong></a> gives clients hassle-free control over theircontent. Through a simple interface youll be able to edit andorganize text, photos, contact information, and othercomponents-all while looking right at your website! Thesoftware is easy to learn, but dont take our word for it-signup for a <a href="http://demo.blueinkcms.com/">freedemo</a>!</p>"} 25
    111. 111. “HTML” ITEM DOC first referenced content item in first{ "_id": "8dd982de76e8b5959e10e6d43600615d", "_rev": "174-aa7546e6308324d4b3ad84469fcbd773", "type": "html", "created": "2008-06-18 15:03:45", "updated": "2009-08-08 13:28:58", "title": "Welcome", "content": "<p>The <a href="http://blueinkcms.com/"><strong>BlueInk Content Management System (CMS)</strong></a> gives clients hassle-free control over theircontent. Through a simple interface youll be able to edit andorganize text, photos, contact information, and othercomponents-all while looking right at your website! Thesoftware is easy to learn, but dont take our word for it-signup for a <a href="http://demo.blueinkcms.com/">freedemo</a>!</p>"} 25
    112. 112. “HTML” ITEM DOC{ "_id": "8dd982de76e8b5959e10e6d43600615d", "_rev": "174-aa7546e6308324d4b3ad84469fcbd773", "type": "html", "created": "2008-06-18 15:03:45", "updated": "2009-08-08 13:28:58", "title": "Welcome", "content": "<p>The <a href="http://blueinkcms.com/"><strong>BlueInk Content Management System (CMS)</strong></a> gives clients hassle-free control over theircontent. Through a simple interface youll be able to edit andorganize text, photos, contact information, and othercomponents-all while looking right at your website! Thesoftware is easy to learn, but dont take our word for it-signup for a <a href="http://demo.blueinkcms.com/">freedemo</a>!</p>"} 25
    113. 113. MAP/REDUCE 26
    114. 114. MAP/REDUCEroute to 26
    115. 115. MAP/REDUCE 26
    116. 116. MAP/REDUCEsorting tools for special 26
    117. 117. MAP/REDUCE 26
    118. 118. MAP/REDUCEincluding the 26
    119. 119. MAP/REDUCE 26
    120. 120. MAP/REDUCEsorting for item in first 26
    121. 121. MAP/REDUCE 26
    122. 122. MAP/REDUCEsorting for item in second 26
    123. 123. MAP/REDUCE 26
    124. 124. MAP/REDUCE doc ids are used by include_docs to bring along the page content/ 26
    125. 125. MAP/REDUCE 26
    126. 126. GETTING THE ABOUT 27
    127. 127. GETTING THE ABOUT db name/site-com/_design/blueink/_list/page/page_and_items ?start_key=[“about”] &end_key=[“about”, {}, {}] &include_docs=true 27
    128. 128. GETTING THE ABOUT/site-com/_design/blueink/_list/page/page_and_items ?start_key=[“about”] &end_key=[“about”, {}, {}] &include_docs=true“page” list function receives output from “page_and_items” view narrowed by the “start_key” and “end_key” with “include_docs=true” to make it all work 27
    129. 129. THEEND 28

    ×