Quantcast
Channel: DreamFactory Forum - Latest topics
Viewing all articles
Browse latest Browse all 1524

NOOB: Help with simple preprocess script

$
0
0

@jimijon wrote:

Hello -

I want to create a simple preprocess script that will read in the query parameters, test for their existence and then to create a filter based upon the parameters. My script never seems to run anything.

var params, required, anon, lastsync, resource, result;
var lodash = require("lodash.min.js");
 

// get query params from request
params = event.request.parameters;

// get resource, /math —> "", /math/add —> "add"  ?
resource = event.resource;
if (resource !== "") {
    // check for required params
    required = ["anon","lastsync"];
    lodash._.each( required, function( element ) {
    if (!params.hasOwnProperty(element) || !params[element]) {
        throw( "Missing '" + element + "' in params\n" );
    }
});
    anon = Number(params.anon);
    lastsync = Number(params.lastsync);

    //WHAT DO I DO WITH THIS?
    //event.request.body.filter = 'id = 1';
    event.request.parameters["filter"]= UNIX_TIMESTAMP(lastUpdate)+" > "+UNIX_TIMESTAMP(lastsync);

}

What am I doing wrong?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1524