module.exports = { "_users/qed_admin": { __configAction: "ignore", _id: "org.couchdb.user:qed_admin", name: "qed_admin", password: "Welkom01", roles: [ "qed_admin" ], type: "user" }, "qed/schemaInfo": { version: "2" }, "qed/_security": { __configAction: "ignore", admins: { names: [], roles: ["qed_admin"] }, readers: { names: [], roles: ["qed_user"] } }, "qed/_design/default": { __configAction: "replace", _id: "_design/default", language: "javascript", validate_doc_update: function(newDoc, oldDoc, userCtx, secObj) { if ( oldDoc && oldDoc.publicationDate ) { throw({forbidden:'Published documents cannot be modified.'}); } }, views: { by_type: { map: function(doc){ emit(doc.type, doc); } }, typeless: { map: function(doc){ if ( !doc.type ) { emit(doc._id, doc); } } } } }, "qed/_design/questions": { __configAction: "replace", _id: "_design/questions", language: "javascript", views: { all: { map: function(doc){ if ( doc.type !== 'Question' ) { return; } if ( doc.categories && doc.categories.length > 0 ) { for ( var i = 0; i < doc.categories.length; i++ ) { emit([doc.categories[i],doc.topic||"(default)"],1); } } else { emit(["(default)","(default)"],1); } }, reduce: function(keys,values){ return sum(values); } }, published: { map: function(doc){ if ( doc.type!=='Question' || !doc.publicationDate ) { return; } if ( doc.categories && doc.categories.length > 0 ) { for ( var i = 0; i < doc.categories.length; i++ ) { emit([doc.categories[i],doc.topic||"(default)"],1); } } else { emit(["(default)","(default)"],1); } }, reduce: function(keys,values){ return sum(values); } }, all_topics: { map: function(doc){ if( doc.type !== 'Question' ){ return; } emit(doc.topic||"(default)",1); }, reduce: function(key, values, rereduce) { return sum(values); } }, published_topics: { map: function(doc){ if ( doc.type !== 'Question' || !doc.publicationDate ) { return; } emit(doc.topic||"(default)",1); }, reduce: function(key, values, rereduce) { return sum(values); } }, all_by_code: { map: function(doc){ if ( doc.type !== 'Question' ) { return; } emit(doc.code,doc); } }, published_by_code: { map: function(doc){ if ( doc.type !== 'Question' || !doc.publicationDate ) { return; } emit(doc.code,doc); } } } }, "qed/_design/surveys": { __configAction: "replace", _id: "_design/surveys", language: "javascript", views: { drafts: { map: function(doc){ if ( doc.type !== 'Survey' || doc.publicationDate ) { return; } emit(doc._id,doc); } }, published: { map: function(doc){ if ( doc.type !== 'Survey' || !doc.publicationDate ) { return; } emit(doc._id,doc); } } } }, "qed/_design/surveyRuns": { __configAction: "replace", _id: "_design/surveys", language: "javascript", views: { by_dates: { map: function(doc){ if ( doc.type !== 'SurveyRun' ) { return; } var startDate = doc.startDate || ""; var endDate = doc.endDate || {}; emit([startDate,endDate,doc.liveName||null],doc); } } } }, "qed/_design/responses": { __configAction: "replace", _id: "_design/responses", language: "javascript", views: { by_surveyrun: { map: function(doc){ if ( doc.type !== 'Response' ) { return; } emit(doc.surveyRunId, doc); } } } } };