tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
785 stars 64 forks source link

Managing DateTime type in documents #7

Open fvisticot opened 6 years ago

fvisticot commented 6 years ago

It seems DateTime type is not supported. I get an exception when trying to add document with DateTime type. Do I need to serialize DateTime properties ? How to make a query based on time ?

alextekartik commented 6 years ago

Thanks for the note. I added some docs regarding supported types: https://github.com/tekartik/sembast.dart/blob/master/doc/data_types.md

Indeed DateTime is not supported currently. I recommend storing them as int (millisSinceEpoch) for sorting and queries

fvisticot commented 6 years ago

Tx for the update. Would be nice to able to query by date based on entity with isoString support. My model is coming from a REST API and I would like to share serialization / deserialization with DB and API.

andreyeurope commented 4 years ago

@alextekartik is this something we will see in the future? (support for DateTime)

alextekartik commented 4 years ago

DateTime is not consistent on Flutter/VM (microseconds precision) and Web (milliseconds precision). Sembast supports Timestamp instead that you convert to and from DateTime.