Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. getCinemaInfo.then( function(data) {
  2. cine.push(data);
  3.  
  4. });
  5.  
  6. function getCinemaInfo()
  7. {
  8. return new Promise(function (resolve, reject) {
  9. MongoClient.connect(url, function (err, client) {
  10. console.log("Connected successfully to server");
  11. const db = client.db('cineitaly');
  12.  
  13. db.collection('cinemas').find({name: item.cinema.trim()}).toArray(function (err, result) {
  14. if (result[0] === "undefined" || result[0] === "") {
  15. result[0] = [];
  16. }
  17. //console.log(result[0]);
  18. // res.status(200).json({cinemas:result[0]});
  19.  
  20.  
  21. if (typeof result[0] === 'undefined') {
  22. console.log("empty array");
  23. }
  24. else {
  25. c = {
  26. "name": item.cinema,
  27. "address": result[0].address,
  28. "number": result[0].number,
  29. "site": result[0].site,
  30. "timeStart": item.programmingTime,
  31. "image": result[0].image,
  32. "latitude": result[0].latitude,
  33. "longitude": result[0].longitude
  34. };
  35. }
  36. });
  37. client.close();
  38. });
  39. resolve(c);
  40. })
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement