How to use the forEachSeries function from async

Find comprehensive JavaScript async.forEachSeries code examples handpicked from public code repositorys.

30
31
32
33
34
35
36
37
38
39
    populate: { path: 'event_category', model: primary.model(constants.MODELS.categories, categoryModel), select: "category_name description event_type" },
    select: 'display_name event_type event_category timestamp status createdAt updatedAt capacity aboutplace personaldetail discounts is_live is_approved isFormSubmitted',
    lean: true
}).then((events) => {
    let allEvents = [];
    async.forEachSeries(events.docs, (event, next_event) => {
        let totalPrice = 0;
        (async () => {
            let noofreview = parseInt(await primary.model(constants.MODELS.eventreviews, eventreviewModel).countDocuments({ eventid: mongoose.Types.ObjectId(event._id) }));
            async.forEach(event.discounts, (discount, next_discount) => {
fork icon0
star icon1
watch icon0

2802
2803
2804
2805
2806
2807
2808
2809
2810
2811

connection.query(sql, function (err, result) {
    closeConnectionCallback(connection, callback);
    if (err)    return callback(err, null);
    obj.liqAgente = result;
    async.forEachSeries(obj.liqAgente, function(f, done) {
        if(f.facturaId) {
            fnFacturaConta(f.facturaId, function (err, rows) {
                if (err) return done(err);
                if (rows.length == 0) {
fork icon0
star icon0
watch icon3

254
255
256
257
258
259
260
261
262
263
const hmails = [];
const ok_paths = [];

let todo_index = 1;

async.forEachSeries(deliveries, (deliv, cb) => {
        const todo = new TODOItem(deliv.domain, deliv.rcpts, transaction);
        todo.uuid = `${todo.uuid}.${todo_index}`;
        todo_index++;
        self.process_delivery(ok_paths, todo, hmails, cb);
fork icon0
star icon0
watch icon1

42
43
44
45
46
47
48
49
50
51
    let obj = {
        rangeStart: rangeStart
    };
    j.push(obj);
}
async.forEachSeries(j, (ele, next_ele) => {
    ( async () => {
        partNum++;
        var end = Math.min(ele.rangeStart + partSize, buffer.length),
        partParams = {
fork icon0
star icon0
watch icon0

22
23
24
25
26
27
28
29
30
31
let allEvents = await primary.model(constants.MODELS.events, eventModel).find({createdBy : { $ne : mongoose.Types.ObjectId(req.token.organizerid)}}).populate([{path : 'event_category', model : primary.model(constants.MODELS.eventcategories, eventcategoryModel), select : 'categoryname'},{path : "createdBy", model : primary.model(constants.MODELS.organizers, organizerModel), select : 'name email mobile country_code profile_pic about' }]).select('photos videos name event_category event_type other createdBy').sort({_id : -1}).lean();
let allOfflineOffers = await primary.model(constants.MODELS.offlineoffers, offlineofferModel).find({ createdBy : { $ne : mongoose.Types.ObjectId(req.token.organizerid)}}).populate({path : "createdBy", model : primary.model(constants.MODELS.organizers, organizerModel), select : 'name email mobile country_code profile_pic about' }).select('offer_title poster video createdBy').sort({_id : -1}).lean();
let allOnlineOffers = await primary.model(constants.MODELS.onlineoffers, onlineofferModel).find({createdBy : { $ne : mongoose.Types.ObjectId(req.token.organizerid)}}).populate({path : "createdBy", model : primary.model(constants.MODELS.organizers, organizerModel), select : 'name email mobile country_code profile_pic about' }).select('shop_name poster images createdBy').sort({_id : -1}).lean();
let allLiveStreaming = await primary.model(constants.MODELS.livestreams, livestreamModel).find({createdBy : { $ne : mongoose.Types.ObjectId(req.token.organizerid)}}).populate([{path : 'event_category', model : primary.model(constants.MODELS.eventcategories, eventcategoryModel), select : 'categoryname'}, {path : "createdBy", model : primary.model(constants.MODELS.organizers, organizerModel), select : 'name email mobile country_code profile_pic about' }]).select('event_name event_category photos videos createdBy').sort({_id : -1}).lean();
async.forEachSeries(allEvents, (event, next_event) => {
    async.forEachSeries(event.photos, (photo, next_photo) => {
        let obj = {
            _id : event._id,
            url : photo.url,
            type : 'event',
fork icon0
star icon0
watch icon0

+ 18 other calls in file

34
35
36
37
38
39
40
41
42
43
(async () => {
    let noofunsold = 0;
    let noofsold = 0;
    let totalseat = 0;
    async.forEachSeries(event.seating_arrangements, (seating_arrangement, next_seating_arrangement) => {
        async.forEachSeries(seating_arrangement.arrangements, (arrangement, next_arrangement) => {
            noofunsold += parseInt(arrangement.total_available_seats);
            noofsold += parseInt(arrangement.total_booked);
            totalseat += parseInt(arrangement.total_seats);
            next_arrangement();
fork icon0
star icon0
watch icon0

+ 2 other calls in file