Last active
October 12, 2015 10:48
-
-
Save rsvalerio/4015154 to your computer and use it in GitHub Desktop.
node couchapp config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var couchapp = require('couchapp'), | |
path = require('path'), | |
ddoc = { | |
_id: '_design/app', | |
views: {}, | |
lists: {}, | |
shows: {}, | |
fulltext: {}, | |
rewrites: [{ | |
from: '/', | |
to: 'index.html' | |
}] | |
}; | |
module.exports = ddoc; | |
ddoc.views.byType = { | |
map: function(doc) { | |
if (doc.type) { | |
emit(doc.type, null); | |
} | |
}, | |
reduce: '_count' | |
}; | |
ddoc.validate_doc_update = function(newDoc, oldDoc, userCtx) { | |
function require(field, message) { | |
message = message || 'Obrigatório: ' + field; | |
if (!newDoc[field]){ | |
throw ({ | |
forbidden: message | |
}); | |
} | |
} | |
if (newDoc.type === 'destino') { | |
require('descricao'); | |
} | |
}; | |
couchapp.loadAttachments(ddoc, path.join(__dirname, 'app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment