Skip to content

Instantly share code, notes, and snippets.

View Rishabh570's full-sized avatar
👋

Rishabh Rawat Rishabh570

👋
View GitHub Profile
[
{
"_id": "2016",
"highestRating": 5.9
},
{
"_id": "1896",
"highestRating": 6
},
{
{
"$project": {
"rating": {
"$round": "$rating"
}
}
},
{
"$group": {
"_id": "$rating",
[
{
"_id": 7,
"movies": 1
},
{
"_id": 8,
"movies": 1
},
{
{
"$group": {
"_id": "$release_year",
"totalRuntime": {
"$sum": "$runtime"
}
}
},
{
"$sort": {
[
{
"_id": "2005",
"totalRuntime": 270
},
{
"_id": "2016",
"totalRuntime": 150
},
{
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!!!`);
async.series([
function(callback) {
setTimeout(function() {
// do some async task
callback(null, 'one');
}, 200);
},
function(callback) {
setTimeout(function() {
// then do another async task
async.parallel([
function(callback) {
setTimeout(function() {
callback(null, 'one');
}, 200);
},
function(callback) {
setTimeout(function() {
callback(null, 'two');
}, 100);
async.race([
function(callback) {
setTimeout(function() {
callback(null, 'one');
}, 200);
},
function(callback) {
setTimeout(function() {
callback(null, 'two');
}, 100);
try {
const resultFromFn1 = await asyncFnThatReturnsOne();
const resultFromFn2 = await asyncFnThatReturnsTwo();
return [resultFromFn1, resultFromFn2];
} catch (err) {
console.log(err);
}