How to query the latest inserted item in with Morphia
And how to get the size of a collection?
How to query the latest inserted item in with Morphia And how to get
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends what you mean by latest, but if you have a Date field with the creation date then you would do this:
T latest = ds.find().sort("-dateCreated").get();And this would get you the count:
int count = ds.getCount(Class.class);