Healy-Hyperspatial / stac-fastapi-mongo

Mongodb backend for stac-fastapi built on the stac-fastapi-elasticsearch core api library.
MIT License
7 stars 1 forks source link

Datetime filtering assumes datetime is stored as string in MongoDB #29

Open GorgiAstro opened 1 month ago

GorgiAstro commented 1 month ago

In the parse_datestring method in stac_fastapi/mongo/utilities.py, which is used for generating the MongoDB query dict, the input time is converted from a string to a python datetime object back to a string. This can only work when the datetime is stored as a string in the MongoDB. However, the recommended way is to store dates/times as datetime objects in the MongoDB. Using my MongoDB where the item's datetime property is stored as a datetime object, queries with datetime filtering always returns no result.

When replacing return dt.strftime("%Y-%m-%dT%H:%M:%SZ") by return dt, then the datetime filtering works for me.

jonhealy1 commented 1 month ago

Can you do a pr for this too? Appreciated

GorgiAstro commented 1 month ago

PR opened in https://github.com/Healy-Hyperspatial/stac-fastapi-mongo/pull/32