Skip to content

Commit 3a4feb6

Browse files
committed
Pipeline bug fixed (complex aggregates supported)
1 parent 29d83f5 commit 3a4feb6

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

packages/dart/lib/src/network/parse_aggregate.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ part of '../../parse_server_sdk.dart';
22

33
class ParseAggregate {
44
final String className;
5-
dynamic pipeline;
5+
Map<String, dynamic> pipeline;
66
final bool? debug;
77
final ParseClient? client;
88
final bool? autoSendSessionId;
@@ -12,14 +12,11 @@ class ParseAggregate {
1212

1313
Future<ParseResponse> execute() async {
1414
Map<String,String> _pipeline={};
15-
if(!((pipeline is Map) || (pipeline is List<Map>))){
16-
throw ArgumentError('pipeline Object should be a Map or a List of Maps. Example1: {"\$group": {"_id": "\$userId", "totalScore": {"\$sum": "\$score"}}} ');
17-
}
1815
if(pipeline.isEmpty){
1916
throw ArgumentError('pipeline must not be empty. Please add pipeline operations to aggregate data. Example: {"\$group": {"_id": "\$userId", "totalScore": {"\$sum": "\$score"}}} ');
2017
}
2118
else{
22-
_pipeline.addAll({'pipeline':jsonEncode(pipeline is List? pipeline : [pipeline])});
19+
_pipeline.addAll({'pipeline':jsonEncode(pipeline.entries.map((e) => {e.key: e.value}).toList())});
2320
}
2421
final debugBool = isDebugEnabled(objectLevelDebug: debug);
2522
final result = await ParseObject(className)._client.get(

0 commit comments

Comments
 (0)