pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21.12k stars 1.03k forks source link

Questions about `date-time` data type #6203

Closed leandrogehlen closed 1 month ago

leandrogehlen commented 1 month ago

I have some questions regarding the date-time data type:

pubkey commented 1 month ago

When you have a field with format: "date-time", then the type is still string. So you can only store plain strings in RxDB. You can do whatever operators or indexing on that. If your date format is sortable, you can apply $gt and index it.

leandrogehlen commented 1 month ago

@pubkey, thanks for the answer.

It could be helpful to have a doc section for this topic

pubkey commented 1 month ago

Yes good idea. I added it to the docs.

leandrogehlen commented 1 month ago

Hello, i'm trying create index on date-time attribute and i'm receiving the follow message. I'm using getRxStorageIndexedDB storage

image

pubkey commented 1 month ago

Please make a PR with a test case. But from your error it looks like you set type: "date-time" which will not work.

leandrogehlen commented 1 month ago

I'm confusing... I understood that date-time type supports index

If your date format is sortable, you can apply $gt and index it.

pubkey commented 1 month ago

But still you need a valid json schema and cannot put date-time as type, only as "format".

leandrogehlen commented 1 month ago

I'm sorry, i did not pay attention about it.