Skip to content

Commit 6db2acd

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
Saad Query Filters #3
1 parent 6eb4398 commit 6db2acd

File tree

9 files changed

+53
-57
lines changed

9 files changed

+53
-57
lines changed

lib/src/api/mixins.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,35 +1127,35 @@ mixin ConditionsMixin {
11271127
/// A mixin that adds the ability to filter a collection of data
11281128
/// on a node.
11291129
mixin QueryableMixin {
1130-
/// List of where() operations to be applied to the query.
1131-
List<WhereQueryFilter> whereFilters = [];
1132-
1133-
/// List of orderBy() operations to be applied to the query.
1134-
List<OrderByQueryFilter> orderByOperations = [];
1135-
11361130
/// Whether to use cloud database.
1137-
late bool useCloudDatabase;
1131+
bool useCloudDatabase = false;
11381132

11391133
/// The path of the collection to query.
1140-
late String? collectionPath;
1134+
String? collectionPath;
11411135

11421136
/// A limit integer to specify the number of documents to be returned.
1143-
late int limit;
1137+
int? limit;
11441138

11451139
/// Whether the query operation is going to be restrictive.
11461140
/// This pertains to Firestore's indexing rules.
11471141
bool get restrictedIndexing => useCloudDatabase;
11481142

1143+
/// List of where() operations to be applied to the query.
1144+
List<WhereQueryFilter> whereFilters = [];
1145+
1146+
/// List of orderBy() operations to be applied to the query.
1147+
List<OrderByQueryFilter> orderByFilters = [];
1148+
11491149
/// Sets the properties of this mixin.
11501150
void setQueryableMixin({
11511151
required List<WhereQueryFilter> whereFilters,
1152-
required List<OrderByQueryFilter> orderByOperations,
1152+
required List<OrderByQueryFilter> orderByFilters,
11531153
required bool useCloudDatabase,
11541154
required String? collectionPath,
1155-
required int limit,
1155+
required int? limit,
11561156
}) {
11571157
this.whereFilters = whereFilters;
1158-
this.orderByOperations = orderByOperations;
1158+
this.orderByFilters = orderByFilters;
11591159
this.useCloudDatabase = useCloudDatabase;
11601160
this.collectionPath = collectionPath;
11611161
this.limit = limit;

lib/src/api/models/action/load_from_cloud_storage_action.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ class LoadFromCloudStorageAction extends ActionModel
4545
super.nonBlocking,
4646
super.enabled,
4747
List<WhereQueryFilter>? whereFilters,
48-
List<OrderByQueryFilter>? orderByOperations,
48+
List<OrderByQueryFilter>? orderByFilters,
4949
int? limit,
5050
}) : super(type: ActionType.loadFromCloudStorage) {
5151
setQueryableMixin(
5252
collectionPath: path,
53-
limit: limit ?? -1,
53+
limit: limit,
5454
whereFilters: whereFilters ?? [],
55-
orderByOperations: orderByOperations ?? [],
56-
useCloudDatabase: false,
55+
orderByFilters: orderByFilters ?? [],
56+
useCloudDatabase: true,
5757
);
5858
}
5959

@@ -64,7 +64,7 @@ class LoadFromCloudStorageAction extends ActionModel
6464
VariableData? variable,
6565
bool? loadSingleDocument,
6666
List<WhereQueryFilter>? whereFilters,
67-
List<OrderByQueryFilter>? orderByOperations,
67+
List<OrderByQueryFilter>? orderByFilters,
6868
int? limit,
6969
}) =>
7070
LoadFromCloudStorageAction(
@@ -73,7 +73,7 @@ class LoadFromCloudStorageAction extends ActionModel
7373
variable: variable ?? this.variable,
7474
loadSingleDocument: loadSingleDocument ?? this.loadSingleDocument,
7575
whereFilters: whereFilters ?? this.whereFilters,
76-
orderByOperations: orderByOperations ?? this.orderByOperations,
76+
orderByFilters: orderByFilters ?? this.orderByFilters,
7777
limit: limit ?? this.limit,
7878
);
7979

@@ -84,7 +84,7 @@ class LoadFromCloudStorageAction extends ActionModel
8484
variable,
8585
loadSingleDocument,
8686
whereFilters,
87-
orderByOperations,
87+
orderByFilters,
8888
limit,
8989
useCloudDatabase,
9090
collectionPath,

lib/src/api/models/action/load_from_cloud_storage_action.g.dart

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/cloud_database_queries/order_by_query_filter.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class OrderByQueryFilter extends QueryFilter with EquatableMixin {
3939
/// parameters.
4040
OrderByQueryFilter copyWith({
4141
String? field,
42-
OrderByQuerySortOrder? operator,
42+
OrderByQuerySortOrder? sortOrder,
4343
}) {
4444
return OrderByQueryFilter(
4545
field: field ?? this.field,
46-
sortOrder: operator ?? this.sortOrder,
46+
sortOrder: sortOrder ?? this.sortOrder,
4747
);
4848
}
4949

lib/src/api/models/cloud_database_queries/where_query_filter.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ enum WhereQueryOperator {
4343
greaterThanOrEqual('Greater Than Or Equal To', '>='),
4444

4545
/// Checks if an array contains a value.
46-
arrayContains('Array Contains', 'array-contains'),
46+
arrayContains('Contains', 'array-contains'),
4747

4848
/// Checks if an array contains any of the values in a given array.
49-
arrayContainsAny('Array Contains Any', 'array-contains-any'),
49+
arrayContainsAny('Contains any', 'array-contains-any'),
5050

5151
/// Checks if a value is in a given array.
52-
inArray('In Array', 'in'),
52+
inArray('Is in', 'in'),
5353

5454
/// Checks if a value is not in a given array.
55-
notInArray('Not In Array', 'not-in');
55+
notInArray('Is not in', 'not-in');
5656

5757
/// The human-readable name of the operation.
5858
final String label;
@@ -79,6 +79,7 @@ enum WhereQueryOperator {
7979
bool get isEqualityOperator =>
8080
this == WhereQueryOperator.equal ||
8181
this == WhereQueryOperator.arrayContains ||
82+
this == WhereQueryOperator.arrayContainsAny ||
8283
this == WhereQueryOperator.inArray;
8384

8485
/// Returns a set of all range operators.
@@ -100,6 +101,7 @@ enum WhereQueryOperator {
100101
static Set<WhereQueryOperator> get equalityOperators => {
101102
WhereQueryOperator.equal,
102103
WhereQueryOperator.arrayContains,
104+
WhereQueryOperator.arrayContainsAny,
103105
WhereQueryOperator.inArray,
104106
};
105107

@@ -127,7 +129,7 @@ class WhereQueryFilter extends QueryFilter with EquatableMixin {
127129
final WhereQueryOperator operator;
128130

129131
/// The value to compare against.
130-
final dynamic value;
132+
final String value;
131133

132134
/// Creates a new [WhereQueryFilter] instance, given a [field], an [operator],
133135
/// and a [value].

lib/src/api/models/cloud_database_queries/where_query_filter.g.dart

Lines changed: 7 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/list_view_node.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class ListViewNode extends SinglePlaceholderNode
6262
// [CloudDatabaseMixin] properties.
6363
bool useCloudDatabase = false,
6464
String? collectionPath,
65-
int limit = 20,
65+
int? limit = 20,
6666
List<WhereQueryFilter>? whereOperations,
67-
List<OrderByQueryFilter>? orderByOperations,
67+
List<OrderByQueryFilter>? orderByFilters,
6868

6969
// [ScrollableMixin] properties.
7070
AxisC scrollDirection = AxisC.vertical,
@@ -101,7 +101,7 @@ class ListViewNode extends SinglePlaceholderNode
101101
collectionPath: collectionPath,
102102
limit: limit,
103103
whereFilters: whereOperations ?? [],
104-
orderByOperations: orderByOperations ?? [],
104+
orderByFilters: orderByFilters ?? [],
105105
);
106106
}
107107

lib/src/api/nodes/list_view_node.g.dart

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/utils.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ typedef HasNode = bool Function(String id);
1818
/// An interface for computing text information. This is meant to be used as an
1919
/// abstraction to Flutter's [TextPainter].
2020
abstract class ITextSizeCalculator {
21+
22+
/// Disposes this instance of [ITextSizeCalculator].
23+
void dispose();
24+
2125
/// Returns the height of a defined [TextNode] based on its width.
2226
/// The details are dependant on the implementation.
2327
double getHeightForWidth(double width);

0 commit comments

Comments
 (0)