I'm a beginner in NodeJS and mongodB and I'm using mongoose and trying to update data of product using this code
return new Promise((resolve, reject) => {
mongoose.connect(DB_URL, { useUnifiedTopology: true, useNewUrlParser: true }).then(() =>
feature = new FaeturesModel({
name: featureName,
description: featureDesc,
catagory: featureCatagory,
price: featurePrice + ' IQD' ,
image: featureImage,
dateOfCreation: new Date().toJSON().slice(0, 10).replace(/-/g, '/')
})).then(() => {
return FaeturesModel.updateOne({"_id" : id} , {$set : {feature}})
.then(()=> feature.save())
.then(() => {
mongoose.disconnect();
resolve()
}).catch(err => {
mongoose.disconnect();
reject(err)
})
}
)
})}
the problem is that the record is added as a new one without deleting the old one