Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- _id: ObjectId,
- language: String (always 2 chars),
- id: String (always 8 chars),
- name: String,
- destination_code: String (always 3 chars),
- cat: Int (in range 1 to 5),
- thumb: String (representing url),
- desc: String,
- geo: Object {lng: Decimal, lat: Decimal},
- address: Object {
- country_code: String (always 2 chars),
- city: String,
- zip: String,
- street: String,
- phone: String,
- fax: String,
- freeflow: Array of strings (ones above),
- country_name: String,
- },
- facilities: Object {
- ...8 fields that can be bool
- },
- details: Object {
- descriptions: Array of objects [
- name: String, content: String
- ],
- images: Array of objects [
- name: String, uri: String (url), thumb: String (url),
- ]
- },
- location: String,
- searchable: String,
- }
- router.get('/locationStaticMapData/:tlc/:location', (req, res) => {
- const flatternGeo = obj => ({
- id: obj.id,
- lat: obj.geo.lat,
- lng: obj.geo.lng,
- })
- const output = []
- const query = {
- destination_code: req.params.tlc,
- location: req.params.location,
- }
- if (req.params.location === '*') delete query.location
- const projection = {
- _id: 0, id: 1, geo: 1,
- }
- const sort = {
- cat: -1,
- }
- let counter = 0
- Global.state.db
- .collection('static_hotel_data')
- .find(query)
- .project(projection)
- .sort(sort)
- .on('data', data => output.push(flatternGeo(data)))
- .on('end', () => res.send(output))
- .on('error', (err) => { throw err })
- })
- _id_ (default index)
- id: 1,
- destination_code: 1,
- location: 1,
- cat: -1,
Add Comment
Please, Sign In to add comment