var job = new cronJob('* * * * * *', function () {
    Draft.find().then(data => {
        var finalData = data;
        finalData.forEach(function(item2) {
            if (item2.scheduledTime === 'now') {
                finalData.forEach(function (item) {
                    var psms = {
                        phoneno: item.senderdata,
                        sender: item.senderName,
                        message: item.message
                    }
                    var obj = psms;
                    var finalpostsms = obj.phoneno.split("\n").map(s => ({ ...obj,
                        phoneno: +s
                    }));
                    Profsms.bulkCreate(finalpostsms).then(function (data) {
                        if (data) {
                            console.log("successfully moved in profsms mysql");
                        } else {
                            console.log("failed");
                        }
                    })
                });
            } else {
                console.log('Better you be in drafts..manual input');
            }
            //delete from draft
            if (item2.scheduledTime === 'now') {
                Draft.findOneAndRemove({
                    _id: item2._id
                }, function (err, employee) {
                    if (err)
                        console.log('err');
                    console.log('Successfully deleted from draft');
                });
            } else {
                console.log('You cant delete from drafts hahaha because no sendnow statement');
            }
        });
    });
}, function () {
    console.log('DelCron Job finished.');
}, true, 'Asia/Calcutta');
This above code, working as asynchronously.
I want the above code to be work as synchronous, need some answers. I am a newbie for JS development
Is it possible to do with async await? i dont know how to write async await code.
 
     
    