javascript – find specific returned loop data node.js

I have this function:

var arrayOfNumbers = []
var getTexts = new cronJob('45 * * * * *', function() {
    var viewConformationEmails = "select * from clients";
    ibmdb.open(ibmdbconn, function(err, conn) {
        if (err) return console.log(err);
        conn.query(viewConformationEmails, function(err, rows) {
            if (err) {
                console.log(err);
            } else if (!err) {
                console.log("Success")
            }


            for (var i = 0; i < rows.length; i++) {
                // arrayOfNumbers.push(rows[i].NAME)


                arrayOfNumbers.push(rows[i]["PHONE_NUMBER"])

                var stringg = rows[i]["MINUTE"] + " " + rows[i]["HOUR"] + " * " + "* " + "*"

                var textJob = new cronJob(stringg, function() {
                    client.messages.create({
                        to: arrayOfNumbers[i],
                        from: '12055578708',
                        body: 'Your training session just finished.'
                    }, function(err, data) {});
                }, null, true);
            }

            conn.close(function() {
                // console.log("closed the function /login");
            });
        });
    });
}, null, true)

what it does is loop through my DB table clients, and then what I want it to do is in the loop grab the phone number, as well as the minute and hour in which the user needs a text message sent to them. However, what I need it to do is ONLY SEND THE MESSAGE TO THE PHONE_NUMBER that has the time slot at x time.

So if the db returns 5 people, but only 1 of those people have a time slot at 9am, then how do i only save that one person, or check for it.

This is a relativley general question to fixing returned loop data so I am just trying to figure out how to fix this. Any ideas?

Read more here: Source link