Skip to content

Instantly share code, notes, and snippets.

@rsvalerio
Last active October 12, 2015 10:48
Show Gist options
  • Save rsvalerio/4015154 to your computer and use it in GitHub Desktop.
Save rsvalerio/4015154 to your computer and use it in GitHub Desktop.
node couchapp config file
'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