Express async parallel callback function

Hi All,

I’m building the local library website project on MDN and came across async parallel.

I understand we are defining a callback functions but not sure what is one: and two: in the below async.parrallel code. Are these function names or variables?

Similarly in the library controller we have book_count: , book_instance_count:, book_instance_available_count:. Is this a way to define a variable or function? Please advise.

var Book = require(’…/models/book’);
var Author = require(’…/models/author’);
var Genre = require(’…/models/genre’);
var BookInstance = require(’…/models/bookinstance’);
var async = require(‘async’);
exports.index = function(req, res) {

async.parallel({
    book_count: function(callback) {
        Book.countDocuments({}, callback); // Pass an empty object as match condition to find all documents of this collection
    },
    book_instance_count: function(callback) {
        BookInstance.countDocuments({}, callback);
    },
    book_instance_available_count: function(callback) {
        BookInstance.countDocuments({status:'Available'}, callback);
    },
    author_count: function(callback) {
        Author.countDocuments({}, callback);
    },
    genre_count: function(callback) {
        Genre.countDocuments({}, callback);
    }
}, function(err, results) {
    res.render('index', { title: 'Local Library Home', error: err, data: results });
});

};

Thanks
Jag

it’s an object. nothing new or different. you have the exact same thing in many places in the rest of your code