Http://hancang2000.i.sohu.com/blog/view/235140698.htm
$mod modulo operation to query the data of age modulo 10 equals 0
Db.student.find ({age: {$mod: [10, 1]}})
Examples are as follows:
The data for the C1 table is as follows:
> Db.c1.find ()
{"_id": ObjectId ("4fb4af85afa87dc1bed94330"), "age": 7, "length_1": 30}
{"_id": ObjectId ("4fb4af89afa87dc1bed94331"), "age": 8, "length_1": 30}
{"_id": ObjectId ("4fb4af8cafa87dc1bed94332"), "age": 6, "length_1": 30}
Query age modulo 6 equals 1 of data
> Db.c1.find ({age: {$mod: [6, 1]}})
{"_id": ObjectId ("4fb4af85afa87dc1bed94330"), "age": 7, "length_1": 30}
It can be seen that only the data of age modulo 6 equals 1 is shown, and other data that does not conform to the rules are not displayed.
The columns of the modulo query must be of number type, other types are not, and the type query that can take the modulo calculation can be useful
MongoDB advanced query to take the model query $mod