Guest User

Untitled

a guest
Nov 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. {
  2. _id: ObjectId,
  3. language: String (always 2 chars),
  4. id: String (always 8 chars),
  5. name: String,
  6. destination_code: String (always 3 chars),
  7. cat: Int (in range 1 to 5),
  8. thumb: String (representing url),
  9. desc: String,
  10. geo: Object {lng: Decimal, lat: Decimal},
  11. address: Object {
  12. country_code: String (always 2 chars),
  13. city: String,
  14. zip: String,
  15. street: String,
  16. phone: String,
  17. fax: String,
  18. freeflow: Array of strings (ones above),
  19. country_name: String,
  20. },
  21. facilities: Object {
  22. ...8 fields that can be bool
  23. },
  24. details: Object {
  25. descriptions: Array of objects [
  26. name: String, content: String
  27. ],
  28. images: Array of objects [
  29. name: String, uri: String (url), thumb: String (url),
  30. ]
  31. },
  32. location: String,
  33. searchable: String,
  34. }
  35.  
  36. router.get('/locationStaticMapData/:tlc/:location', (req, res) => {
  37. const flatternGeo = obj => ({
  38. id: obj.id,
  39. lat: obj.geo.lat,
  40. lng: obj.geo.lng,
  41. })
  42. const output = []
  43. const query = {
  44. destination_code: req.params.tlc,
  45. location: req.params.location,
  46. }
  47. if (req.params.location === '*') delete query.location
  48. const projection = {
  49. _id: 0, id: 1, geo: 1,
  50. }
  51. const sort = {
  52. cat: -1,
  53. }
  54. let counter = 0
  55. Global.state.db
  56. .collection('static_hotel_data')
  57. .find(query)
  58. .project(projection)
  59. .sort(sort)
  60. .on('data', data => output.push(flatternGeo(data)))
  61. .on('end', () => res.send(output))
  62. .on('error', (err) => { throw err })
  63. })
  64.  
  65. _id_ (default index)
  66. id: 1,
  67. destination_code: 1,
  68. location: 1,
  69. cat: -1,
Add Comment
Please, Sign In to add comment