Nic Cottrell
Nic Cottrell

Reputation: 9665

How do I reverse sort natural in Morphia?

I have a capped collection and I know I need to issue:

find().sort({$natural:-1})

to sort by most recent first. But how do I do this in Morphia?

query.order("-$natural"); // doesn't work

Upvotes: 2

Views: 1123

Answers (1)

Nic Cottrell
Nic Cottrell

Reputation: 9665

Found a solution: disable validation just after creating the query object and everything functions as expected.

Upvotes: 1

Related Questions