order static method
Constructs an order/sorting query for MongoDB.
The orderBy parameter specifies the field to order by.
The orderReverse parameter controls the sorting direction: descending (-1) if true (default), ascending (1) if false.
Returns null if orderBy is null or invalid (e.g., an email).
Example:
var query = DQ.order('field', true); // { 'field': -1 }
Implementation
static Map<String, Object>? order(
String? orderBy, [
bool orderReverse = true,
]) {
if (orderBy == null || orderBy.isEmail) {
return null;
}
return {orderBy: orderReverse ? -1 : 1};
}