MongoDB: How to get N decimals precision in a query

前端 未结 4 875
庸人自扰
庸人自扰 2021-01-25 04:58

Given the following documents in a MongoDB collection...

{ \"_id\": 1, \"amount\": { \"value\": 1.123456789999, \"rate\": 1.2 }}
{ \"_id\": 2, \"amount\": { \"va         


        
4条回答
  •  庸人自扰
    2021-01-25 05:11

    you can just use the regex operator

    db.test.find({ value: { $regex: 1\.12[0-9]*}})
    

提交回复
热议问题