Question

MongoDB Reader Dynamic JSON Query Date

  • 6 December 2022
  • 1 reply
  • 6 views

Is it possible in the MongoDB reader to have a JSON Query similar to

{"_id" : { "gte" : { "$date" : "@DateTimeFormat(@DateTimeAdd(@DateTimeNow(local),-P7D),%Y-%m-%dT%H:%M:00.000)Z" } } }

I have tried putting the entirety into a User Parameter, but the date section does not get calculated before being sent to MongoDB, leading to a warning being of the following.

MONGODB3 reader: Feature Type Parametr 'mongodb_query_document' has invalid value '{"_id" : { "gte" : { "$date" : "@DateTimeFormat(@DateTimeAdd(@DateTimeNow(local)' for feature type


1 reply

Userlevel 1
Badge +15

Hi @svteshipley​ thanks for your question! I am not 100% sure if this would be possible straight from the reader. However, you might be able to create an attribute value from the user parameter (e.g. AttributeCreator/AttributeManager) that does calculate the date properly and then use a FeatureReader to read in from MongoDB using the new attribute value as the query.

 

If this does not work please let us know and we can try to investigate this further.

Reply