I\'m querying Mongo in Nodejs with Mongoose and attempting to extract the numeric value of multiple fields stored as a Decimal128. However, the value is oddly wrapped in que
Working solution
const mongoose = require('mongoose')
const parentSchemaSymbol = mongoose.model('Stock')
exports.dbFetch = (req, res) => {
let curValueDbFetch = req.params.symbol
const query = { symbol: `${curValueDbFetch}` }
const projection = { _id: 0, data: 1 }
parentSchemaSymbol.findOne(query, projection).sort({ date: -1 }).then(doc => {
let chartData = doc.data.map(item => {
return {
date: parseFloat(item.date), // the date
open: parseFloat(item.open), // open
high: parseFloat(item.high), // high
low: parseFloat(item.low), // low
close: parseFloat(item.close), // close
volume: parseFloat(item.volume)// volume
}
})
res.send(chartData)
})
.catch(e => {
console.log(e)
})
}