Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Retrieve element from list in hive

I have a list in hive of events each with an eventId field. In order to retrieve a specific event, I can retrieve the list from hive and do this to get the one I want.

var hiveEvents = HiveEvents.getAllEvents();
var ev = hiveEvents.firstWhere((event) => event.eventId == 8);

Is there a better way to pull just the event out of hive by passing the id, or is this the correct way to do it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As it is written in the docs:

Hive does not have a query language and only has limited support for sorting, which is not necessarily a disadvantage, as you can see in the benchmark. Sorting and filtering are much faster if you do it yourself in Dart.

So getting the list and using List methods is the way to do that in Hive.

If you need to be able to query your data, you can use Isar which is a package from the same developer.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading