I\'m trying to query my database for prices greater than/less than a user specified number. In my database, prices are stored like so:
{price: \"300.00\"} >
Starting Mongo 4.0, there is a new $toDouble aggregation operator which converts from various types to double (in this case from a string):
Mongo 4.0
// { price: "300.00" } // { price: "4.2" } db.collection.find({ $expr: { $gt: [{ $toDouble: "$price" }, 30] } }) // { price: "300.00" }