Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Backendless.ServerCode.addTimer({
  2.  
  3.         //...
  4.  
  5.     execute(req) {
  6.         logger.info("started timer");
  7.  
  8.         var PlaceStore = Backendless.Data.of("Place");
  9.         var placeDataQuery = new Backendless.DataQuery();
  10.  
  11.         return PlaceStore.find(placeDataQuery).then(
  12.             places => {
  13.             logger.info("places: " + places.data.length);
  14.  
  15.             return Promise.all(places.data.map(place => {
  16.                 logger.info("in loop: " + place.objectId);
  17.  
  18.                 return findAllPlaceHits(place.objectId).then(hits => {
  19.                     logger.info("hits: " + hits.data.length);
  20.  
  21.                     //here I believe you need to do something with place and its hits
  22.                     //don't forget to _return_ a new promise from here
  23.                 }).catch(function(err) {
  24.                     return Promise.reject('Unable update place hit to true and return new attendance count : ' + err.message)
  25.                 });
  26.             }));
  27.           },
  28.           error => Promise.reject('Unable to get places : ' + err.message));
  29.     }
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement