Skip to main content

MongoSorts

Definition of the sorts in Bson that are used in MongoDB collection queries.


ascending​


ascending(fieldNames: string[]) : org.bson.conversions.Bson​

Description​

Creates an ascending sort for the given fields.

How To Use​
collection.find().sort(_mongo.sorts().ascending('name')).all();
Attributes​
NAMETYPEDESCRIPTION
fieldNamesstring[]The field names.
Return​

( org.bson.conversions.Bson )

The sort.


ascending(fieldNames: java.util.List<string>) : org.bson.conversions.Bson​

Description​

Creates an ascending sort from a list of field names.

Attributes​
NAMETYPEDESCRIPTION
fieldNamesjava.util.ListThe list of field names.
Return​

( org.bson.conversions.Bson )

The sort.


descending​


descending(fieldNames: string[]) : org.bson.conversions.Bson​

Description​

Creates a descending sort for the given fields.

How To Use​
collection.find().sort(_mongo.sorts().descending('date')).all();
Attributes​
NAMETYPEDESCRIPTION
fieldNamesstring[]The field names.
Return​

( org.bson.conversions.Bson )

The sort.


descending(fieldNames: java.util.List<string>) : org.bson.conversions.Bson​

Description​

Creates a descending sort from a list of field names.

Attributes​
NAMETYPEDESCRIPTION
fieldNamesjava.util.ListThe list of field names.
Return​

( org.bson.conversions.Bson )

The sort.


orderBy​


orderBy(sorts: org.bson.conversions.Bson[]) : org.bson.conversions.Bson​

Description​

Combines multiple sorts into a single sort.

How To Use​
collection.find().sort(_mongo.sorts().orderBy(_mongo.sorts().ascending('name'), _mongo.sorts().descending('date'))).all();
Attributes​
NAMETYPEDESCRIPTION
sortsorg.bson.conversions.Bson[]The sorts to combine.
Return​

( org.bson.conversions.Bson )

The combined sort.


orderBy(sorts: java.util.List<?>) : org.bson.conversions.Bson​

Description​

Combines multiple sorts from a list.

Attributes​
NAMETYPEDESCRIPTION
sortsjava.util.ListThe list of sorts to combine.
Return​

( org.bson.conversions.Bson )

The combined sort.