module.exports = { "_users/qed_admin": { __configAction: "ignore", _id: "org.couchdb.user:qed_admin", name: "qed_admin", password: "Welkom01", roles: [ "qed_admin" ], type: "user" }, "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); } } } }, "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||null],1); } } else { emit([null,null],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||null],1); } } else { emit([null,null],1); } }, reduce: function(keys,values){ return sum(values); } }, all_topics: { map: function(doc){ if( doc.type !== 'Question' ){ return; } emit(doc.topic); }, reduce: function(key, values, rereduce) { return null; } }, published_topics: { map: function(doc){ if ( doc.type !== 'Question' || !doc.publicationDate ) { return; } emit(doc.topic); }, reduce: function(key, values, rereduce) { return null; } } } }, "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/responses": { __configAction: "replace", _id: "_design/responses", language: "javascript", views: { by_surveyrun: { map: function(doc){ if ( doc.type !== 'Response' ) { return; } emit(doc.surveyRunId, doc); } } } } };