Good day everyone i've been trying to force the data of my Json.stringify to int because on my mongodb it returns as string so on my schema i need to do it like this first
var UserSchema = mongoose.Schema({
username:{
type: String,
index:true
},
influenceid:{
type:String
},
question:{
type:String
},
amount:{
type:String //i need this to be a type:Number instead of string
}
});
and on my dialog.js where in i put the json data
socket.emit('dollar quest', JSON.stringify(result[0]),
JSON.stringify(result[1]), inUserId, myuserid, 'dquest');
and on my server i fetch data like this to throw it to my mongodb
socket.on('dollar quest', function(dolquest,dolamnt,uid,stud,stat){
var info = new InfoUser({
username: stud,
amount: dolamnt,
question: dolquest
});
InfoUser.createUser(info,function(err,user){
if(err)throw err;
console.log(user);
});
});
But the output on my mlab is like this
"username": "stsam1",
"amount": "\"12500\"",
"question": "\"how are you\"",
How can i turn my amount into type:Number so that it will return on my mlab as like this
"amount": 12500,