Hi,

I want my getmongo processor to fetch the data of past 2 days only. So I
referred this link to create a function and call that function from the
query field in getmongo processor:  https://stackoverflow.com/que
stions/44573618/how-to-get-iso-string-in-nifi-getmongo-query
-field/44725438#44725438

Function to get a date:

db.system.js.save({

    "_id": "dd",

    "value": function() {

          var todayTime = new Date();

    var yesterday = new Date()

         yesterday.setDate(todayTime.getDate() - 2)

    var month = yesterday.getMonth() + 1;

    var day = yesterday.getDate();

    var year = yesterday.getFullYear().toString().substr(-2);

    var prev_date=month + "/" + day + "/" + year;

    return prev_date;

}

});

Query to fetch all the data that is greater than the calculated date:

{"$where": "Incident Submitted Dt": $gte: dd()}

I am getting a Json parse exception in the processor:

'Query validated against '{"$where": "Incident Submitted Dt": $gte: dd()}'
is invalid because org.son.json.JsonParseException.


I am sure the query is wrong, but I don't know how to write a valid query.


Request you to help!!


Thanks,

Faustina

Reply via email to