Q:

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

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
Example: user input a number to the system with value : 69923994, then I use this input to search my database for all documents that have this value between the range of the fields LOC_CEP_INI and LOC_CEP_FIM.
One of my documents (in this example this document is selected by the query because the input is inside the range):
 {
   "_id" : ObjectId("570d57de457405a61b183ac6"),
   "LOC_CEP_FIM" : 69923999, //this field is number
   "LOC_CEP_INI" : 69900001, // this field is number
   "LOC_NO" : "RIO BRANCO",
   "LOC_NU" : "00000016",
   "MUN_NU" : "1200401",
   "UFE_SG" : "AC",
   "create_date" : ISODate("2016-04-12T20:17:34.397Z"),
   "__v" : 0
}

A:

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 .

