1 | module.exports = { |
---|
2 | "_users/qed_admin": { |
---|
3 | __configAction: "ignore", |
---|
4 | _id: "org.couchdb.user:qed_admin", |
---|
5 | name: "qed_admin", |
---|
6 | password: "Welkom01", |
---|
7 | roles: [ "qed_admin" ], |
---|
8 | type: "user" |
---|
9 | }, |
---|
10 | "qed/_security": { |
---|
11 | __configAction: "ignore", |
---|
12 | admins: { |
---|
13 | names: [], |
---|
14 | roles: ["qed_admin"] |
---|
15 | }, |
---|
16 | readers: { |
---|
17 | names: [], |
---|
18 | roles: ["qed_user"] |
---|
19 | } |
---|
20 | }, |
---|
21 | "qed/_design/default": { |
---|
22 | __configAction: "replace", |
---|
23 | _id: "_design/default", |
---|
24 | language: "javascript", |
---|
25 | validate_doc_update: function(newDoc, oldDoc, userCtx, secObj) { |
---|
26 | if ( oldDoc && oldDoc.publicationDate ) { throw({forbidden:'Published documents cannot be modified.'}); } |
---|
27 | }, |
---|
28 | views: { |
---|
29 | by_type: { |
---|
30 | map: function(doc){ |
---|
31 | emit(doc.type, doc); |
---|
32 | } |
---|
33 | } |
---|
34 | } |
---|
35 | }, |
---|
36 | "qed/_design/questions": { |
---|
37 | __configAction: "replace", |
---|
38 | _id: "_design/questions", |
---|
39 | language: "javascript", |
---|
40 | views: { |
---|
41 | all: { |
---|
42 | map: function(doc){ |
---|
43 | if ( doc.type !== 'Question' ) { return; } |
---|
44 | if ( doc.categories && doc.categories.length > 0 ) { |
---|
45 | for ( var i = 0; i < doc.categories.length; i++ ) { |
---|
46 | emit([doc.categories[i],doc.topic||null],1); |
---|
47 | } |
---|
48 | } else { |
---|
49 | emit([null,null],1); |
---|
50 | } |
---|
51 | }, |
---|
52 | reduce: function(keys,values){ return sum(values); } |
---|
53 | }, |
---|
54 | published: { |
---|
55 | map: function(doc){ |
---|
56 | if ( doc.type!=='Question' || !doc.publicationDate ) { return; } |
---|
57 | if ( doc.categories && doc.categories.length > 0 ) { |
---|
58 | for ( var i = 0; i < doc.categories.length; i++ ) { |
---|
59 | emit([doc.categories[i],doc.topic||null],1); |
---|
60 | } |
---|
61 | } else { |
---|
62 | emit([null,null],1); |
---|
63 | } |
---|
64 | }, |
---|
65 | reduce: function(keys,values){ return sum(values); } |
---|
66 | }, |
---|
67 | all_topics: { |
---|
68 | map: function(doc){ |
---|
69 | if( doc.type !== 'Question' ){ return; } |
---|
70 | emit(doc.topic); |
---|
71 | }, |
---|
72 | reduce: function(key, values, rereduce) { return null; } |
---|
73 | }, |
---|
74 | published_topics: { |
---|
75 | map: function(doc){ |
---|
76 | if ( doc.type !== 'Question' || !doc.publicationDate ) { return; } |
---|
77 | emit(doc.topic); |
---|
78 | }, |
---|
79 | reduce: function(key, values, rereduce) { return null; } |
---|
80 | } |
---|
81 | } |
---|
82 | }, |
---|
83 | "qed/_design/surveys": { |
---|
84 | __configAction: "replace", |
---|
85 | _id: "_design/surveys", |
---|
86 | language: "javascript", |
---|
87 | views: { |
---|
88 | drafts: { |
---|
89 | map: function(doc){ |
---|
90 | if ( doc.type !== 'Survey' || doc.publicationDate ) { return; } |
---|
91 | emit(doc._id,doc); |
---|
92 | } |
---|
93 | }, |
---|
94 | published: { |
---|
95 | map: function(doc){ |
---|
96 | if ( doc.type !== 'Survey' || !doc.publicationDate ) { return; } |
---|
97 | emit(doc._id,doc); |
---|
98 | } |
---|
99 | } |
---|
100 | } |
---|
101 | }, |
---|
102 | "qed/_design/responses": { |
---|
103 | __configAction: "replace", |
---|
104 | _id: "_design/responses", |
---|
105 | language: "javascript", |
---|
106 | views: { |
---|
107 | by_surveyrun: { |
---|
108 | map: function(doc){ |
---|
109 | if ( doc.type !== 'Response' ) { return; } |
---|
110 | emit(doc.surveyRunId, doc); |
---|
111 | } |
---|
112 | } |
---|
113 | } |
---|
114 | } |
---|
115 | }; |
---|