Closed micheleriva closed 5 years ago
Hey @micheleriva.
While it's possible to use DateTime
, NaiveDateTime
and other special structs as values in Memento/Mnesia table records, they need to be normalized into a scalar type before you can perform queries on them (sort of similar to how you would do it with any other database).
Memento is meant to provide the absolute essentials and type conversions should be handled by you. You could write helper functions that convert DateTime into unix timestamps when writing, and back to DateTime when reading. Once it's been normalized into an integer, you can use your query above to get the records.
For nested tuples or maps when dealing with complex data-types (such as datetime with timezone), you might want to consider using select_raw/3
or :qlc
.
Here are some other links:
Thank you so much, that's a clear answer!
Hi! First of all, thanks for this library, is awesome! I have a little problem querying Mnesia by date: I need to get every record where
:creation_date
is less than 24 hours ago.I am writing the following method:
For the
run_query
method, I've followed your example.When I run the
select_by_date
method, I get the following error:Is there a way to compare dates during the query?