vicinityManager/server/services/items/update.js
/*
Update several items
Can choose to execute any of the actions below for each item.
OPTIONS: Enable, disable, update metadata/accessLevel/avatar ...
*/
Update several items
Can choose to execute any of the actions below for each item.
OPTIONS: Enable, disable, update metadata/accessLevel/avatar
Update several items Can choose to execute any of the actions below for each item . OPTIONS : Enable disable update metadata / accessLevel / avatar
function updateManyItems(items, roles, email, cid, c_id, uid, callback){
  if(items.length !== 0){ 
    logger.debug('Start async handler...');
    sync.forEachAll(items,
      function(value, allresult, next, otherParams) {
        if(value.status === 'enabled'){
          enableItem(value, otherParams, function(value, result, success) {
            allresult.push({value: value, error: result, success: success});
            next();
          });
        }else if(value.status === 'disabled'){
          disableItem(value, otherParams, function(value, result, success) {
            allresult.push({value: value, error: result, success: success});
            next();
          });
        } else {
          updateItem(value, otherParams, function(value, result, success) {
            allresult.push({value: value, error: result, success: success});
            next();
          });
        }
      },
      function(allresult) {
        if(allresult.length === items.length){
          logger.debug('Completed async handler: ' + JSON.stringify(allresult));
          callback(false, allresult);
        }
      },
      false,
      {roles: roles, email: email, cid:cid, c_id:c_id, uid:uid}
    );
  }
}
function updateManyItems ( items , roles , email , cid , c_id , uid , callback ) { if ( items . length !== 0 ) { logger . debug ( 'Start async handler...' ) ; sync . forEachAll ( items , function ( value , allresult , next , otherParams ) { if ( value . status === 'enabled' ) { enableItem ( value , otherParams , function ( value , result , success ) { allresult . push ( { value : value , error : result , success : success } ) ; next ( ) ; } ) ; } else if ( value . status === 'disabled' ) { disableItem ( value , otherParams , function ( value , result , success ) { allresult . push ( { value : value , error : result , success : success } ) ; next ( ) ; } ) ; } else { updateItem ( value , otherParams , function ( value , result , success ) { allresult . push ( { value : value , error : result , success : success } ) ; next ( ) ; } ) ; } } , function ( allresult ) { if ( allresult . length === items . length ) { logger . debug ( 'Completed async handler: ' + JSON . stringify ( allresult ) ) ; callback ( false , allresult ) ; } } , false , { roles : roles , email : email , cid : cid , c_id : c_id , uid : uid } ) ; } }
Update several items
Can choose to execute any of the actions below for each item.
Update several items Can choose to execute any of the actions below for each item .
// Check if there is any item to update