I am using a library called Hive which is a very fast NoSQL database. I have everything set up and I am trying to get the values in reverse order (Last in First Out).
I have a box of entries, each entry has a creation date and an entry text. As you can see in the code that whenever an entry is created the date of it is "Now". I want to get the list of entries starting from the most recent entry (latest date). by default, the first entry added using box.add() will have a key of 0, the one after it is 1, and etc. In Hive's documentation, it says that fetching the values can be done "in reverse lexicographic order" but I wasn't able to figure it out.
Thanks in advance!
import 'package:hive/hive.dart';
part '../type_adapters/entry.g.dart';
@HiveType(typeId: 0)
class Entry extends HiveObject {
@HiveField(0)
String _entryText;
@HiveField(1)
DateTime _creationDate;
Entry(this._entryText) {
_creationDate = DateTime.now();
}
String get entryText => _entryText;
DateTime get creationDate => _creationDate;
@override
String toString() {
return "$_entryText, $_creationDate, $key";
}
}
library link: Hive Hive Documentation