async loop with mongoose

Solutions on MaxInterview for async loop with mongoose by the best coders in the world

showing results for - "async loop with mongoose"
Blake
26 Jun 2017
1// Sort by symbol, skip the first 5, return at most 20, and don't hydrate
2// the returned doc. See https://mongoosejs.com/docs/api.html#model_Model.hydrate
3const query = Stock.find().sort({ symbol: 1 }).skip(5).limit(20).lean();
4for await (const stock of query) {
5  const price = await superagent.
6    get(`https://api.iextrading.com/1.0/stock/${stock.symbol}/price`).
7    then(res => res.body);
8  console.log(stock.symbol, price);
9  // No `save()` because `stock` is lean
10}
similar questions
queries leading to this page
async loop with mongoose