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(); await userCollection.save();
} }
let user = await user.findById(userId); let founduser = await user.findById(userId);
if (!user) { if (!founduser) {
return res.status(404).json({ message: "User not found" }); return res.status(404).json({ message: "User not found" });
} }
// update number of cars in the collection // update number of cars in the collection
user.number_of_cars = userCollection.cars.length; founduser.number_of_cars = userCollection.cars.length;
await user.save(); await founduser.save();
// 7) Return success // 7) Return success
return res.status(201).json({ return res.status(201).json({