server/lib/master/index.js
//Updates a single element (flags only).
Updates a single element (flags only).
Updates a single element ( flags only ) .
function postMaster(request, response, element) {
  db = app.get("db_conn");
  db.collection(element, function(err, coll) {
    if (err) {
      throw err;
    }
    var objectID = new ObjectId(request.body.identifier);
    var updateCount = 0;
    var updateMax = 3;
    function updateDone() {
      if (updateCount = updateMax) {
        console.log("record updated, count: " + updateCount + " id: " + request.body.identifier + " element: " + element);
        response.statusCode = 200;
        response.end();
      }
    }
    if (request.body.approved) {
      coll.update({
        "_id": objectID,
        'owner': request.user.username
      }, {
        $set: {
          approved: request.body.approved
        }
      }, function(err, results) {
        if (err) {
          throw err;
        }
        updateCount = updateCount + 1;
        updateDone();
      });
    } else {
      updateCount = updateCount + 1;
      updateDone();
    }
    if (request.body.ignored) {
      coll.update({
        "_id": objectID,
        'owner': request.user.username
      }, {
        $set: {
          ignored: request.body.ignored
        }
      }, function(err, results) {
        if (err) {
          throw err;
        }
        updateCount = updateCount + 1;
        updateDone();
      });
    } else {
      updateCount = updateCount + 1;
      updateDone();
    }
    if (request.body.archived) {
      coll.update({
        "_id": objectID,
        'owner': request.user.username
      }, {
        $set: {
          archived: request.body.archived
        }
      }, function(err, results) {
        if (err) {
          throw err;
        }
        updateCount = updateCount + 1;
        updateDone();
      });
    } else {
      updateCount = updateCount + 1;
      updateDone();
    }
  });
}
function postMaster ( request , response , element ) { db = app . get ( "db_conn" ) ; db . collection ( element , function ( err , coll ) { if ( err ) { throw err ; } var objectID = new ObjectId ( request . body . identifier ) ; var updateCount = 0 ; var updateMax = 3 ; function updateDone ( ) { if ( updateCount = updateMax ) { console . log ( "record updated, count: " + updateCount + " id: " + request . body . identifier + " element: " + element ) ; response . statusCode = 200 ; response . end ( ) ; } } if ( request . body . approved ) { coll . update ( { "_id" : objectID , 'owner' : request . user . username } , { $set : { approved : request . body . approved } } , function ( err , results ) { if ( err ) { throw err ; } updateCount = updateCount + 1 ; updateDone ( ) ; } ) ; } else { updateCount = updateCount + 1 ; updateDone ( ) ; } if ( request . body . ignored ) { coll . update ( { "_id" : objectID , 'owner' : request . user . username } , { $set : { ignored : request . body . ignored } } , function ( err , results ) { if ( err ) { throw err ; } updateCount = updateCount + 1 ; updateDone ( ) ; } ) ; } else { updateCount = updateCount + 1 ; updateDone ( ) ; } if ( request . body . archived ) { coll . update ( { "_id" : objectID , 'owner' : request . user . username } , { $set : { archived : request . body . archived } } , function ( err , results ) { if ( err ) { throw err ; } updateCount = updateCount + 1 ; updateDone ( ) ; } ) ; } else { updateCount = updateCount + 1 ; updateDone ( ) ; } } ) ; }
Updates a single element (flags only).
Updates a single element ( flags only ) .