Skip to content

Commit 29d83f5

Browse files
committed
no message
1 parent c093ff1 commit 29d83f5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/dart/example/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ Future<void> main() async {
2727
r'$match': {'Name': 'Ketogenic'}
2828
}).execute();
2929

30-
print(res);
30+
print(res.result);
3131
}

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

Lines changed: 5 additions & 2 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-
Map<String, dynamic> pipeline;
5+
dynamic pipeline;
66
final bool? debug;
77
final ParseClient? client;
88
final bool? autoSendSessionId;
@@ -12,11 +12,14 @@ 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+
}
1518
if(pipeline.isEmpty){
1619
throw ArgumentError('pipeline must not be empty. Please add pipeline operations to aggregate data. Example: {"\$group": {"_id": "\$userId", "totalScore": {"\$sum": "\$score"}}} ');
1720
}
1821
else{
19-
_pipeline.addAll({'pipeline':jsonEncode([pipeline])});
22+
_pipeline.addAll({'pipeline':jsonEncode(pipeline is List? pipeline : [pipeline])});
2023
}
2124
final debugBool = isDebugEnabled(objectLevelDebug: debug);
2225
final result = await ParseObject(className)._client.get(

0 commit comments

Comments
 (0)