search

Home  >  Q&A  >  body text

mongodb - Is this a $mod query bug? Can't use divisor with more than 11 digits?

I collected data from an administrative division and used the following command to query provincial-level data
db.collection.find({'_id':{$mod: [10000000000,0]}})
No data was returned
Normally the following data needs to be returned

{
    "_id" : NumberLong("110000000000"),
    "name" : "北京市"
},

/* 2 */
{
    "_id" : NumberLong("120000000000"),
    "name" : "天津市"
},

/* 3 */
{
    "_id" : NumberLong("130000000000"),
    "name" : "河北省"
},
...

I can use a 10-digit divisor to return data after removing a 0, but it is not what I need.
Is this a $mod bug?
There are no relevant instructions in the official documentation.

大家讲道理大家讲道理2788 days ago555

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-02 09:26:54

    I tested it, and now it is:

    1. Under mongo shell, the situation is the same as you described;

    2. Under mongodb driver 2.2.24, the situation is the same as you described;

     error: null
     result: undefined
    

    3.mongoose driver 4.7.9,

      error : Can't use $mod with ObjectId.
    

    It is recommended to visit: https://jira.mongodb.org/secu... ; and submit an issue for tracking.

    For reference.

    Love MongoDB! Have Fun!

    ------------------------Gorgeous separator--------------------- ----------

    MongoDB Chinese community has many offline activities, please click below:

    2017 Huashan Sword Discussion|MongoDB Chinese Community

    Hangzhou Station is coming in March! ! ! Interested friends please sign up quickly! ! !

    reply
    0
  • Cancelreply