Am having issues with converting object value from Number to String in mongodb using mongoose, if I try to change it to a String type it saves without having any errors, but when I console.log typeof
saved data it still shows Number
. Also if I change the value to a string it turns to a string e.g st.bankaccnum = "you are"
it throws error,(Cast to Number failed). But users data are already stored in database and I would like to turn everything to a String type.
User.find({bankaccname: {$exists: 1}}, function(err,user){
user.forEach(function(st){
let num = st.bankaccnum;
st.bankaccnum = new String(st.bankaccnum);
st.save(function(err,saved){
if(err){
console.log(err)
} else {console.log(typeof saved.bankaccnum)}
})
})
})