Changeset 492 for Dev/trunk/src/server/config
- Timestamp:
- 03/09/14 14:23:42 (11 years ago)
- Location:
- Dev/trunk/src/server/config
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/server/config/check-couchdb.js
r487 r492 1 1 var Q = require('q') 2 2 , _ = require('underscore') 3 , tv4 = require('tv4')3 , validator = require('../util/validator') 4 4 , CouchDB = require('../util/couch').CouchDB 5 5 ; … … 10 10 var server = new CouchDB(couchServerURL,dbName); 11 11 var designRe = /^_design\//; 12 13 var codes = {}; 14 function codeUnique(code) { 15 if ( code in codes ) { 16 return false; 17 } else { 18 codes[code] = true; 19 return true; 20 } 21 } 22 12 23 return server.get('/_all_docs') 13 24 .then(function(allDocs){ … … 20 31 return server.get(doc.id) 21 32 .then(function(doc){ 22 var valid = tv4.validateResult(doc,schema); 33 var valid = validator(doc,schema); 34 if ( doc.type === "Question" && !codeUnique(doc.code) ) { 35 valid.valid = false; 36 valid.error = "Question code "+doc.code+" is not unique."; 37 } 23 38 result[doc._id] = valid; 24 39 return result; -
Dev/trunk/src/server/config/couchdb-design-docs.js
r487 r492 125 125 }, 126 126 127 "qed/_design/surveyRuns": { 128 __configAction: "replace", 129 _id: "_design/surveys", 130 language: "javascript", 131 views: { 132 by_dates: { 133 map: function(doc){ 134 if ( doc.type !== 'SurveyRun' ) { return; } 135 var startDate = doc.startDate || ""; 136 var endDate = doc.endDate || {}; 137 emit([startDate,endDate,doc.liveName||null],doc); 138 } 139 } 140 } 141 }, 142 127 143 "qed/_design/responses": { 128 144 __configAction: "replace", -
Dev/trunk/src/server/config/couchdb-schema.json
r487 r492 36 36 "_rev": { "type": "string" }, 37 37 "categories": { "type": "array", "items": { "type": "string" } }, 38 "code": { "type": "string" },38 "code": { "type": "string", "minLength": 1 }, 39 39 "content": { "type": "array", "items": { "$ref": "#/definitions/content/any" } }, 40 40 "description": { "type": "string" }, … … 52 52 "_id": { "type": "string" }, 53 53 "_rev": { "type": "string" }, 54 "description": { "type": "string" }, 54 55 "publicationDate": { "type": "string", "format": "datetime" }, 55 56 "questions": { "type": "array", "items": { "$ref": "#/definitions/docs/Question" } }, … … 67 68 "description": { "type": "string" }, 68 69 "endDate": { "type": "string", "format": "datetime" }, 70 "liveName": { "type": "string" }, 69 71 "mode": { "type": "string", "enum": [ "open", "closed" ] }, 70 "secret": { "type": "string", "minLength": 8 }, 72 "respondentCanDeleteOwnResponse": { "type": "boolean" }, 73 "secret": { "type": "string", "minLength": 1 }, 71 74 "startDate": { "type": "string", "format": "datetime" }, 72 75 "survey": { "$ref": "#/definitions/docs/Survey" }, … … 83 86 "_rev": { "type": "string" }, 84 87 "answers": { "type": "object" }, 88 "email": { "type": "string", "format": "email" }, 85 89 "publicationDate": { "type": "string", "format": "datetime" }, 86 "secret": { "type": "string", "minLength": 8},90 "secret": { "type": "string", "minLength": 1 }, 87 91 "surveyRunId": { "type": "string" } 88 92 }, -
Dev/trunk/src/server/config/upgrade-couchdb.js
r487 r492 1 1 var Q = require('q') 2 2 , _ = require('underscore') 3 , tv4 = require('tv4')4 3 , CouchDB = require('../util/couch').CouchDB 5 4 ;
Note: See TracChangeset
for help on using the changeset viewer.