Morphia query example : greaterThan(), lessThan(), greaterThanOrEq(), lessThanOrEq()

Morphia query example : greaterThan(), lessThan(), greaterThanOrEq(), lessThanOrEq()

Morphia’s fluent api allows you to perform¬†queries using comparison on a given field.
greaterThan() and lessThan() correspond to the $gt and $lt mongoDB operators respectively. As their name implies, they allow you to perform greater than or less than queries.
greaterThanOrEq() and lessThanOrEq() correspond to the $gte and $lte mongoDB operators respectively. This time they allow you to perform greater than or equals or less than or equals comparisons for your queries.

Note that if the tested field is an array or collection, the query will return entities where at least one of the entries in the array match the comparison.

 

References

Morphia documentation wiki @ gtihub.com

Morphia Query official documentation

MongoDB $gt documentation

MongoDB $lt documentation

MongoDB $gte documentation

MongoDB $lte documentation

Leave a Reply

Your email address will not be published. Required fields are marked *