Skip to content

Instantly share code, notes, and snippets.

@stephepush
Created September 13, 2021 02:12
Show Gist options
  • Save stephepush/c924111b30b7974f97873963b002513f to your computer and use it in GitHub Desktop.
Save stephepush/c924111b30b7974f97873963b002513f to your computer and use it in GitHub Desktop.
Excluding model/class properties in express
exports.postAddVehicle = (req, res, next) => {
const model_year = req.body.model_year;
const make = req.body.make;
const model = req.body.model;
const color = req.body.color;
const miles = req.body.miles;
const transmission = req.body.transmission;
const layout = req.body.layout;
const engine_config = req.body.engine_config;
const car_photo_url = null;
const car_price = null;
const car = new Car(
null, model_year, make, model,
color, miles, transmission, layout, engine_config
)
console.log(car)
/* car
.save()
.then(() => {
res.redirect('/');
})
.catch(err => console.log(err)) */
}
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;
this.model = model;
this.miles = miles;
this.color = color;
this.transmission = transmission;
this.layout = layout;
this.engine_config = engine_config;
this.car_photo_url = car_photo_url;
this.car_price = car_price
}
Car {
id: null,
model_year: '2016',
make: 'Chevrolet',
model: 'Corvette',
miles: 'violet',
color: '56000',
transmission: 'automatic',
layout: 'MR',
engine_config: 'V8',
car_photo_url: undefined,
car_price: undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment