quick fix

This commit is contained in:
Jonathan Jara 2025-06-09 14:11:44 -07:00
parent a4c2ffa119
commit 0d26b512e3

View File

@ -50,14 +50,14 @@ exports.createCar = async (req, res) => {
await userCollection.save();
}
let user = await user.findById(userId);
if (!user) {
let founduser = await user.findById(userId);
if (!founduser) {
return res.status(404).json({ message: "User not found" });
}
// update number of cars in the collection
user.number_of_cars = userCollection.cars.length;
await user.save();
founduser.number_of_cars = userCollection.cars.length;
await founduser.save();
// 7) Return success
return res.status(201).json({