Using async/await in model method, passing it into controller method in Express MVC w/ node-pg

Solution for Using async/await in model method, passing it into controller method in Express MVC w/ node-pg
is Given Below:

I’m trying to get a model method (dealing with ‘Read’ from CRUD) working with a controller in the node app I’m building, which would render a list of cars pulled from a postgres db in an EJS template using async/await. Here’s the model method:

const { query, pool } = require('./database');

module.exports = class Car {
    
      constructor( 
        id, model_year, make, model, miles,
        color, transmission, layout, engine_config, car_photo_url, car_price ) {
            this.id = id;
            this.model_year = model_year;
            this.make = make;...
      }
        //method I'm working on
        static fetchAll = async() => {
            try {
                let results= await query('SELECT * FROM cars');
                console.log(results)
            } catch (err) {
                console.log(err)
            }
           
            //console.log(results.rows)
            return results
            
        }

The controller file/method (../controllers/admin):

const Car = require('../models/car');

exports.getVehicles = (req, res, next) => {
        let rows = Car.fetchAll();
        console.log(rows)
        res.render('admin/vehicles', {
            cars: rows,
            pageTitle: 'Dealer Admin Page',
            path: '/admin/vehicles'
        });
} 

routes/admin.js using express-promise-router:

const Router = require('express-promise-router')

const express = require('express');

const adminController = require('../controllers/admin')

const router = new Router()
...

router.get('/vehicles', adminController.getVehicles);
...
})


module.exports = router;

Frontend Template using EJS:

<%- include('../includes/head.ejs') %>
</head>
<body>
    <%- include('../includes/nav.ejs') %>

    <main class="container py-5">
        <% if (cars.length > 0) { %>
            <section class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
                <% for (let car of cars) { %>
                    <article class="col">
                        <div class="card shadow-sm">
                          <svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"/><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text></svg>
              
                          <div class="card-body">
                            <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                            <div class="d-flex justify-content-between align-items-center">
                              <div class="btn-group">
                                <button type="button" class="btn btn-sm btn-outline-secondary">View</button>
                                <button type="button" class="btn btn-sm btn-outline-secondary">Edit</button>
                              </div>
                              <small class="text-muted">9 mins</small>
                            </div>
                          </div>
                        </div>
                      </div>
                    </article>
                    <% } %>
            </section>
            <% } else { %>
                <h2>No Cars Found!</h2>
                <% } %>
    </main>
    <%- include('../includes/end.ejs') %>

When I console.log(rows), I get back Promise { <pending> } and I can’t figure out how to show the actual rows. How do I show successfully fetch(?) the rows from the postgres database using async/wait syntax in this situation? Should I restructure things in a different way?