I collected data from an administrative division and used the following command to query provincial datadb.collection.find({'_id':{$mod: [10000000000,0]}})
No return data
It is normal to return the following data
{
"_id" : NumberLong("110000000000"),
"name": "Beijing"
},
/* 2 */
{
"_id" : NumberLong("120000000000"),
"name": "Tianjin City"
},
/* 3 */
{
"_id" : NumberLong("130000000000"),
"name": "Hebei Province"
},
...
I can use a 10-bit divisor to return data after removing a 0, but this is not my requirement.
Is this a bug for $mod?
There are no relevant instructions in the official documents.
Seek solutions
I have tried it out, and now it is:
1, mongo shell, the same situation as you described;
2. Under mongodb driver 2.2.24, the situation described by you is the same.
error: null result: undefined
3、mongoose driver 4.7.9,
error : Can't use $mod with ObjectId.
Suggested visit:https://jira.mongodb.org/secu …; And submit an issue to follow up.
For reference.
Love MongoDB! Have Fun!
-Gorgeous Splitter-
MongoDB Chinese Community has many activities offline. Please poke at the bottom:
2017 Hua Shan Lun Jian |MongoDB Chinese Community
Hangzhou station is approaching in March! ! ! Interested friends quickly sign up! ! !