function show (req, res) {
      console.log('From : ' + req.params.id);
      console.log('To : '   + req.params.destinationId)
      let airportDest = '';
      Flight.findById({_id: req.params.id}).where("destination").exec(function (err, flightDest) {
         //+ Get the airport destination
            for (let i = 0 ; i < flightDest.destination.length ; i++) {
               if (`${flightDest.destination[i]._id}` === `${req.params.destinationId}`) {
                  airportDest = flightDest.destination[i].airport;
                  break;
               }
            }
         //+ Get the airport destination - Samething using a forEach
            // flightDest.destination.forEach((dest) => {
            //    if (`${dest.id}` === `${req.params.destinationId}`) {
            //       airportDest = dest.airport;
            //    }
            // });
         Ticket.find({destFlight: req.params.destinationId}).sort({seat: 1}).exec( function(err, tickets) {
            res.render("tickets/new", {
               tickets: tickets,
               originFlightId: req.params.id,
               destinationFlightId: req.params.destinationId,
               title: `${flightDest.airport} to ${airportDest}`
            });
         });
      });
   }
//! Render the show/new tickets
Render the show/new tickets
Render the show / new tickets
function show (req, res) {
      console.log('From : ' + req.params.id);
      console.log('To : '   + req.params.destinationId)
      let airportDest = '';
      Flight.findById({_id: req.params.id}).where("destination").exec(function (err, flightDest) {
            for (let i = 0 ; i < flightDest.destination.length ; i++) {
               if (`${flightDest.destination[i]._id}` === `${req.params.destinationId}`) {
                  airportDest = flightDest.destination[i].airport;
                  break;
               }
            }
          - Samething using a forEach
         Ticket.find({destFlight: req.params.destinationId}).sort({seat: 1}).exec( function(err, tickets) {
            res.render("tickets/new", {
               tickets: tickets,
               originFlightId: req.params.id,
               destinationFlightId: req.params.destinationId,
               title: `${flightDest.airport} to ${airportDest}`
            });
         });
      });
   }
function show ( req , res ) { console . log ( 'From : ' + req . params . id ) ; console . log ( 'To : ' + req . params . destinationId ) let airportDest = '' ; Flight . findById ( { _id : req . params . id } ) . where ( "destination" ) . exec ( function ( err , flightDest ) { for ( let i = 0 ; i < flightDest . destination . length ; i ++ ) { if ( ` ${ flightDest . destination [ i ] . _id } ` === ` ${ req . params . destinationId } ` ) { airportDest = flightDest . destination [ i ] . airport ; break ; } } Ticket . find ( { destFlight : req . params . destinationId } ) . sort ( { seat : 1 } ) . exec ( function ( err , tickets ) { res . render ( "tickets/new" , { tickets : tickets , originFlightId : req . params . id , destinationFlightId : req . params . destinationId , title : ` ${ flightDest . airport } ${ airportDest } ` } ) ; } ) ; } ) ; }
Render the show/new tickets
Render the show / new tickets
//+ Get the airport destination //+ Get the airport destination - Samething using a forEach // flightDest.destination.forEach((dest) => { //    if (`${dest.id}` === `${req.params.destinationId}`) { //       airportDest = dest.airport; //    } // });