SQL Record pre-processing not saving records

var lodash = require("lodash");

if (event.request.payload.resource) {
    lodash._.each(event.request.payload.resource, function( record ) {
        record.user_name = platform.session.user.name;
        console.log(record.user_name);
    });
}

The script I am using currently. I know it executes the script and even changes the record.user_name. But it is not saved in database. What could be the issue.