Open CodeWithSouma opened 3 years ago
isGold
When we call rental post route ( like this http://localhost:3000/api/rentals/) with given value
http://localhost:3000/api/rentals/
{ "customerId":"5f6f53afb53731ef06d7c01e", "movieId":"5f6f5180b53731ef06d7c01c" }
although our customer is Gold customer it is not assign in rental document it shows isGold:false .
Gold
isGold:false
{ "_id": "5f6f55548ac0e2f2c6532571", "customer": { "isGold": false, "_id": "5f6f53afb53731ef06d7c01e", "name": "Soumadip Dey", "phone": "8768454982" }, "movie": { "_id": "5f6f5180b53731ef06d7c01c", "title": "Ratsasant", "dailyRentalRate": 20 }, "dateOut": "2020-09-26T14:51:00.943Z", "__v": 0 }
It's happening for the rental schema's customer customer child schema's isGold default value
customer
isGold: { type: Boolean, default: false }
We need to override isGold property in rental api's post route like this
customer: { _id: customer._id, name: customer.name, phone: customer.phone, isGold:customer.isGold }
One of the properties of customer
isGold
is not override in rentals apiWhen we call rental post route ( like this
http://localhost:3000/api/rentals/
) with given valuealthough our customer is
Gold
customer it is not assign in rental document it showsisGold:false
.It's happening for the rental schema's
customer
customer child schema'sisGold
default valuesollution
We need to override
isGold
property in rental api's post route like this