Changeset 487 for Dev/trunk/src/server/config/couchdb-design-docs.js
- Timestamp:
- 03/05/14 22:44:48 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/server/config/couchdb-design-docs.js
r480 r487 11 11 12 12 "qed/schemaInfo": { 13 version: " 1"13 version: "2" 14 14 }, 15 15 … … 31 31 language: "javascript", 32 32 validate_doc_update: function(newDoc, oldDoc, userCtx, secObj) { 33 if ( oldDoc && oldDoc.publicationDate ) { throw({forbidden:'Published documents cannot be modified.'}); } 33 if ( oldDoc && oldDoc.publicationDate ) { 34 throw({forbidden:'Published documents cannot be modified.'}); 35 } 34 36 }, 35 37 views: { … … 59 61 if ( doc.categories && doc.categories.length > 0 ) { 60 62 for ( var i = 0; i < doc.categories.length; i++ ) { 61 emit([doc.categories[i],doc.topic|| null],1);63 emit([doc.categories[i],doc.topic||"(default)"],1); 62 64 } 63 65 } else { 64 emit([ null,null],1);66 emit(["(default)","(default)"],1); 65 67 } 66 68 }, … … 72 74 if ( doc.categories && doc.categories.length > 0 ) { 73 75 for ( var i = 0; i < doc.categories.length; i++ ) { 74 emit([doc.categories[i],doc.topic|| null],1);76 emit([doc.categories[i],doc.topic||"(default)"],1); 75 77 } 76 78 } else { 77 emit([ null,null],1);79 emit(["(default)","(default)"],1); 78 80 } 79 81 }, … … 83 85 map: function(doc){ 84 86 if( doc.type !== 'Question' ){ return; } 85 emit(doc.topic );87 emit(doc.topic||"(default)",1); 86 88 }, 87 reduce: function(key, values, rereduce) { return null; }89 reduce: function(key, values, rereduce) { return sum(values); } 88 90 }, 89 91 published_topics: { 90 92 map: function(doc){ 91 93 if ( doc.type !== 'Question' || !doc.publicationDate ) { return; } 92 emit(doc.topic );94 emit(doc.topic||"(default)",1); 93 95 }, 94 reduce: function(key, values, rereduce) { return null; } 96 reduce: function(key, values, rereduce) { return sum(values); } 97 }, 98 by_code: { 99 map: function(doc){ 100 if ( doc.type !== 'Question' ) { return; } 101 emit(doc.code,doc); 102 } 95 103 } 96 104 }
Note: See TracChangeset
for help on using the changeset viewer.