DQ class
A utility class for building MongoDB queries.
The DQ class provides a set of static methods to construct MongoDB-compatible queries
in a more readable and structured way. It allows for easy creation of complex queries
with operations such as equality checks, logical operations (\$or
, \$and
), pattern matching,
and aggregation commands like grouping and sorting.
Example Usage:
var query = DQ.and([
DQ.field('name', DQ.like('John')),
DQ.field('age', DQ.eq(25)),
]);
var result = await collection.find(query).toList();
Constructors
- DQ.new()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
$field(
String field) → String -
and(
List< Object?> list) → Map<String, Object?> - Constructs a logical AND query.
-
cond(
{required Object ifCond, required Object thenCond, required Object elseCond}) → Map< String, Object> -
count(
String field) → Map< String, Object> -
dateToString(
{required Object field, String format = '%Y-%m-%d %H:%M:%S', Object? onNull, Object? onError, String? timezone}) → Map< String, Object> -
eq(
Object? value) → Object? - Returns a value for equality comparison.
-
field(
String name, Object? query) → Map< String, Object?> - Constructs a query for a specific field.
-
group(
Map< String, Object?> query) → Map<String, Object> - Constructs a MongoDB aggregation group stage.
-
gt(
Object? value) → Map< String, Object?> -
gte(
Object? value) → Map< String, Object?> -
hasIn(
Object? value) → Map< String, Object?> - Matches documents where the field's value is in the provided list.
-
hasNin(
Object? value) → Map< String, Object?> - Matches documents where the field's value is not in the provided list.
-
id(
String id) → Map< String, Object?> - Matches a document based on a string ID.
-
like(
String value, {String options = 'i'}) → Map< String, Object?> - Matches documents where the field's value matches a regular expression.
-
limit(
int limit) → Map< String, Object> -
lookup(
{required String from, required String localField, String foreignField = '_id', String? as}) → Map< String, Object> -
lt(
Object? value) → Map< String, Object?> -
lte(
Object? value) → Map< String, Object?> -
match(
List< Map< matches) → Map<String, Object?> >String, Object> -
oid(
ObjectId id) → Map< String, Object?> - Matches a document based on its ObjectId.
-
or(
List< Object?> list) → Map<String, Object?> - Constructs a logical OR query.
-
order(
String? orderBy, [bool orderReverse = true]) → Map< String, Object> ? - Constructs an order/sorting query for MongoDB.
-
pipeline(
List< Map< query) → List<String, Object> >Map< String, Object> > -
project(
Map< String, Object> fields) → Map<String, Object> -
skip(
int skip) → Map< String, Object> -
sort(
Map< String, int> fields) → Map<String, Object> -
sortField(
String field, [bool desc = true]) → Map< String, int> -
sortList(
List< Map< fields) → Map<String, int> >String, Object> -
sortOne(
String field, [bool desc = true]) → Map< String, Object> -
sum(
String field) → Map< String, Object?> - Constructs a sum aggregation operation.
-
sumQuery(
Object query) → Map< String, Object> -
toDate(
String field) → Map< String, Object> -
uncase(
String value) → Map< String, Object?> - Matches documents where the field's value is case-insensitive.
-
unwind(
{required String path, String? as, bool? preserveNullAndEmptyArrays}) → Map< String, Object>