How to use a for loop in the mongodb shell?
<p>How can i use a for loop in the mongo db shell?</p>

<p>My attemps are stucking at this point:</p>

<pre><code>for (var i = 0; i &lt;= 6; i=i+0.12){
var n = i + 0.12;
db.test.aggregate(
    { $sort: {'deviation': -1}},
    { $unwind: '$foo' },
    { $match: { 'foo.km': {$gt: {n}, $lt: {i}}}},
    { $limit: 1}
)
}
</code></pre>

<p>Thanks for help!</p>