Self-triggered perpetually running Firebase process using NodeJS

I have a set of records that I would like to update sequentially in perpetuity. Basically:

  1. Get least recently updated record
  2. Update record
  3. Set date of record to now (aka. send it to the back of the list)
  4. Back to step 1

Here is what I was thinking using Firebase:

// update record function
var updateRecord = function() {

    // get least recently updated record
    firebaseOOO.limit(1).once('value', function(snapshot) {
        key = _.keys(snapshot.val())[0];

        /*
         * do 1-5 seconds of non-Firebase processing here
         */

        snapshot.ref().child(key).transaction(

            // update record
            function(data) {
                return updatedData;
            },

            // update priority after commit (would like to do it in transaction)
            function(error, committed, snap2) {
                snap2.ref().setPriority(snap2.dateUpdated);
            }
        );
    });
};

// listen whenever priority changes (aka. new item needs processing)
firebaseOOO.on('child_moved', function(snapshot) {
    updateRecord();
});

// kick off the whole thing
updateRecord();

Is this a reasonable thing to do?

In general, this type of daemon is precisely what was envisioned for use with the Firebase NodeJS client. So, the approach looks good.

However, in the on() call it looks like you're dropping the snapshot that's being passed in on the floor. This might be application specific to what you're doing, but it would be more efficient to consume that snapshot in relation to the once() that happens in the updateRecord().