Select data where the range between two different fields contains a given number

后端 未结 3 788
旧巷少年郎
旧巷少年郎 2020-12-11 10:24

I want to make a find query on my database for documents that have an input value between or equal to these 2 fields, LOC_CEP_INI and LOC_CEP_FIM

3条回答
  •  心在旅途
    2020-12-11 11:12

    db.collection.find( { field: { $gt: value1, $lt: value2 } } );
    

    https://docs.mongodb.com/v3.2/reference/method/db.collection.find/ refer this mongo provide range facility with $gt and $lt .

提交回复
热议问题