isar / hive

Lightweight and blazing fast key-value database written in pure Dart.
Apache License 2.0
4.1k stars 407 forks source link

Could we use unique strings as typeId? #505

Open saschaernst opened 3 years ago

saschaernst commented 3 years ago

Question How can I use custom hive types in a library without risking a conflicting typeId being used by another package or an app when it is adding my code respectively?

Would it be possible to use a fully qualified name (i.e. com.somedomain.somelibraryname.someid) as type id? having a range of just 200something integers seems a bit unreliable.

Cheers, Sascha

Tienisto commented 3 years ago

AFAIK there is also a DateTimeAdapter with id 16. So there is a probability that the developer accidentally hit this number without using any third-party package except hive

saschaernst commented 3 years ago

Wow, you are right! https://github.com/hivedb/hive/blob/875a6c6c8e65547f9206de6bc30ef5b91ff1b89e/hive/lib/src/adapters/date_time_adapter.dart I cannot imagine that it is that crucial to use an integer at that point instead of a string.