This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"_id": "2016", | |
"highestRating": 5.9 | |
}, | |
{ | |
"_id": "1896", | |
"highestRating": 6 | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$project": { | |
"rating": { | |
"$round": "$rating" | |
} | |
} | |
}, | |
{ | |
"$group": { | |
"_id": "$rating", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"_id": 7, | |
"movies": 1 | |
}, | |
{ | |
"_id": 8, | |
"movies": 1 | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$group": { | |
"_id": "$release_year", | |
"totalRuntime": { | |
"$sum": "$runtime" | |
} | |
} | |
}, | |
{ | |
"$sort": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"_id": "2005", | |
"totalRuntime": 270 | |
}, | |
{ | |
"_id": "2016", | |
"totalRuntime": 150 | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
someAsyncOperation(function (err, data) { | |
if (err) { | |
console.log(`Some error occurred. Look at it => ${err}`); | |
} else { | |
data.forEach((item, index) { | |
asyncProcessingOfItem(item, function (itemErr, isProcessed) { | |
if (itemErr) { | |
console.log(`Some error occurred while processing item. Here's that beast => ${err}`); | |
} else if (isProcessed) { | |
console.log(`${item} processed succesfully!!!`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.series([ | |
function(callback) { | |
setTimeout(function() { | |
// do some async task | |
callback(null, 'one'); | |
}, 200); | |
}, | |
function(callback) { | |
setTimeout(function() { | |
// then do another async task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.parallel([ | |
function(callback) { | |
setTimeout(function() { | |
callback(null, 'one'); | |
}, 200); | |
}, | |
function(callback) { | |
setTimeout(function() { | |
callback(null, 'two'); | |
}, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.race([ | |
function(callback) { | |
setTimeout(function() { | |
callback(null, 'one'); | |
}, 200); | |
}, | |
function(callback) { | |
setTimeout(function() { | |
callback(null, 'two'); | |
}, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
const resultFromFn1 = await asyncFnThatReturnsOne(); | |
const resultFromFn2 = await asyncFnThatReturnsTwo(); | |
return [resultFromFn1, resultFromFn2]; | |
} catch (err) { | |
console.log(err); | |
} |