1. 100 entries are generated
VaR A = new array (100); // There Is. foreach. I don't know why I can only use for (VAR I = 0; I <. length; I ++) {dB. test. insert ({X: I})} // who knows how to write in the JS shell provided by Mongo?CodeLine feed
Using dB. Test. Find (), you can see that the database has been imported into the database. Enter the it command to view more information on the page.
2. Add 1 to the data that can be modeled by 2.
> Var cursor = dB. test. find ();> cursor. foreach (function (m) {M. X % 2 & (dB. test. update ({X: M. X },{ $ Inc {X: 1}); print (M. x )})
Create a cursor and use the cursor iterator foreach provided by Mongo to perform operations.
3. Use dB. Test. Find () to check the results. You can see that the database has been updated.
PS:
Code line feed
For () {// press ENTER
... // Will appear...
...} // Press ENTER
Will be executed