Advertisement
Guest User

Untitled

a guest
Nov 19th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ardata=new Array();
  2.        ardata.push("justtesting");
  3.         async.series([
  4.     function(callback){
  5.                  for(var i=0;i<=request.body.contact.length-1;i++)
  6.             {
  7.              if(request.body.contact[i].tempid)
  8.                 {
  9.                     var o=request.body.contact[i];
  10.                     pair=Object.keys(o).map(function(a){ return [a, o[a]] });
  11.                     AM.addcontact(pair,request.session.user,request.body.contact.length,function(e,o){
  12.                         if(!o)
  13.                         {
  14.                              response.send('something went wrong'+e);
  15.            
  16.                         }
  17.                         else
  18.                         {
  19.                            ardata.push(o);
  20.                         }
  21.        
  22.                     });
  23.                    
  24.                    
  25.                 }
  26.                 /*else if(request.body.contact[i].cid)
  27.                 {
  28.                     var o=request.body.contact[i];
  29.                     pair=Object.keys(o).map(function(a){ return [a, o[a]] });
  30.                     AM.updatecontact(pair,request.session.user,function(e,o){
  31.                         if(!o)
  32.                         {
  33.                              response.send('something went wrong'+e);
  34.            
  35.                         }
  36.                         else
  37.                         {
  38.                             showtouser.push(o);
  39.                             response.send(showtouser);
  40.                         }
  41.        
  42.                     });
  43.        
  44.                 }*/
  45.                 else
  46.                 {
  47.                   response.send('please provide atleast cid or tempid for insertion or updation of contacts');
  48.                 }
  49.                
  50.             }
  51.         callback(null, ardata);
  52.     },
  53.     function(callback){
  54.         // do some more stuff ...
  55.         ardata.push("just testing part 2!");
  56.         callback(null, ardata);
  57.     }
  58. ],
  59. // optional callback
  60. function(err, results){
  61. response.send(results);
  62.     // results is now equal to ['one', 'two']
  63. });
  64.  
  65. /* HERE IS THE OUTPUT
  66.  
  67. [
  68.   [
  69.     "justtesting",
  70.     "just testing part 2!"
  71.   ],
  72.   [
  73.     "justtesting",
  74.     "just testing part 2!"
  75.   ]
  76. ]
  77. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement