Horje
async loop with mongoose Code Example
async loop with mongoose
// Sort by symbol, skip the first 5, return at most 20, and don't hydrate
// the returned doc. See https://mongoosejs.com/docs/api.html#model_Model.hydrate
const query = Stock.find().sort({ symbol: 1 }).skip(5).limit(20).lean();
for await (const stock of query) {
  const price = await superagent.
    get(`https://api.iextrading.com/1.0/stock/${stock.symbol}/price`).
    then(res => res.body);
  console.log(stock.symbol, price);
  // No `save()` because `stock` is lean
}




Javascript

Related
makestyle server side rendering Code Example makestyle server side rendering Code Example
redux dispatch input onchange Code Example redux dispatch input onchange Code Example
jquery maximum value of an element by class Code Example jquery maximum value of an element by class Code Example
angry professor javascript Code Example angry professor javascript Code Example
save array file Code Example save array file Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8