Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GorgiAstro opened this issue Oct 15, 2024 · 2 comments
Open

Comments

@GorgiAstro
Copy link

GorgiAstro commented Oct 15, 2024

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
Copy link
Contributor

Can you do a pr for this too? Appreciated

@GorgiAstro
Copy link
Author

PR opened in #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants