Skip to content

Commit 384f2aa

Browse files
committed
refactor(country): improve type safety in aggregate pipeline
- Update pipeline variable type from Map<String, dynamic> to Map<String, Object> - Ensure consistent use of generic type <String, Object> for pipeline stages - Apply proper casting for nested map objects in match and group stages
1 parent ba6185f commit 384f2aa

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/src/services/country_service.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,31 +276,33 @@ class CountryService {
276276
'with nameFilter: $nameFilter.',
277277
);
278278
try {
279-
final pipeline = <Map<String, dynamic>>[
280-
{
281-
r'$match': {
279+
final pipeline = <Map<String, Object>>[
280+
<String, Object>{
281+
r'$match': <String, Object>{
282282
'status': ContentStatus.active.name,
283-
'$fieldName.id': {r'$exists': true},
283+
'$fieldName.id': <String, Object>{r'$exists': true},
284284
},
285285
},
286286
];
287287

288288
// Add name filter if provided
289289
if (nameFilter != null && nameFilter.isNotEmpty) {
290-
pipeline.add({
291-
r'$match': {'$fieldName.name': nameFilter},
292-
});
290+
pipeline.add(
291+
<String, Object>{
292+
r'$match': <String, Object>{'$fieldName.name': nameFilter},
293+
},
294+
);
293295
}
294296

295297
pipeline.addAll([
296-
{
297-
r'$group': {
298+
<String, Object>{
299+
r'$group': <String, Object>{
298300
'_id': '\$$fieldName.id',
299-
'country': {r'$first': '\$$fieldName'},
301+
'country': <String, Object>{r'$first': '\$$fieldName'},
300302
},
301303
},
302-
{
303-
r'$replaceRoot': {'newRoot': r'$country'},
304+
<String, Object>{
305+
r'$replaceRoot': <String, Object>{'newRoot': r'$country'},
304306
},
305307
]);
306308

0 commit comments

Comments
 (0)