Advertisement
fmunoz92

Untitled

Sep 15th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. exports.fillApps= function(req, res){
  3.  
  4.  
  5.   async.each(MockApps, function( app, callback) {
  6.       App.findOne({name: app.name}, function (err, app) {
  7.           if (err) {
  8.               return callback(err);
  9.               logger.error('error funding app', err);
  10.           }
  11.           //logger.debug(app);
  12.  
  13.           if (app) {
  14.               app.stripeID = app.stripeID || null;
  15.               app.imageUrl = app.imageUrl || null;
  16.               app.monthlyPrice = app.monthlyPrice || null;
  17.               app.status = app.status || null;
  18.               app.category = app.category || null;
  19.               app.learnMore = app.learnMore || null;
  20.               app.visibleBy = app.visibleBy || null;
  21.               app.descriptions = app.descriptions || null;
  22.               app.tag = app.tag || null;
  23.               app.features =app.features || null;
  24.               app.save(function (err, app) {
  25.                   if (err) logger.error('error chargin app', err);
  26.                   logger.debug('fill with ' + app.name);
  27.                   callback();
  28.               });
  29.           } else {
  30.               var newApp = new App(app);
  31.               //logger.debug(tmpIndex);
  32.               newApp.save(function (err, app) {
  33.                   if (err) logger.error('error chargin app', err);
  34.                   callback();
  35.               });
  36.           }
  37.       });
  38.   }, function(err){
  39.       if( err ) {
  40.         res.send(...)
  41.  
  42.       } else {
  43.         res.send(...)
  44.  
  45.       }
  46.   });
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement