Open pablisco opened 6 years ago
I don't think we want to use count
because it requires that the query backing the cursor traverse its entire result set. So if you query for a million items but end up only taking 5 calling count
will traverse over the entire million to return an accurate number.
Good point, would isBeforeFirst
be a better call? I do hope not many people have 5 million records on their app database (but wouldn't surprise me either hehe)
I was also contemplating creating a toSequence(Cursor.() -> T) : Sequence<T>
which would may make it easier to use. But I'm not sure if it's out of the scope of ktx as it's kind of a new feature.
Extends
Cursor
to provide functions to check i the cursor is empty or notUsage