Does anyone have any idea how to retrieve the last(with the newest date) entity in objectify? I know how to make a query but how to retrieve the one with the newest date?
List<Transaction> fetched2 = ofy.query(Transaction.class).filter("someproperty", somepropertyvalue).order("date").list();
I could try to bubble sort it but I´m sure there is an easier way. THX
You just have to add a minus in front of "date" in your order :
List<Transaction> fetched2 = ofy.query(Transaction.class).filter("someproperty", somepropertyvalue).order("-date").list();
That should return you a list of Transaction with the newest one in first position.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With