Skip to main content
Question

MongoDB Reader Dynamic JSON Query Date

  • December 6, 2022
  • 1 reply
  • 26 views

svteshipley
Contributor
Forum|alt.badge.img

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

evieatsafe
Safer
  • Safer
  • December 13, 2022

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings