public
Description: A real time CouchDB chat demo
Homepage: http://jchrisa.net/toast/_design/toast/index.html
Clone URL: git://github.com/jchris/toast.git
toast / validate_doc_update.js
100644 15 lines (13 sloc) 0.383 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function (newDoc, oldDoc, userCtx) {
  function forbidden(message) {
    throw({forbidden : message});
  };
  
  function unauthorized(message) {
    throw({unauthorized : message});
  };
 
  if (userCtx.roles.indexOf('_admin') == -1) {
    // admin can edit anything, only check when not admin...
    if (newDoc._deleted)
      forbidden("You may not delete a doc.");
  }
}