Skip to content

Commit 8b018b9

Browse files
committed
fix(data): Enable iso_code search for countries
- Added iso_code search to country model - Updated documentation examples
1 parent 586f7d6 commit 8b018b9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

routes/api/v1/data/index.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ Future<Response> onRequest(RequestContext context) async {
8585
/// - Other parameters for categories will result in a 400 Bad Request.
8686
///
8787
/// - **Countries (`model=country`):**
88-
/// - Filterable ONLY by `q` (text query on name only).
89-
/// Example: `/api/v1/data?model=country&q=United`
88+
/// - Filterable ONLY by `q` (text query on name and isoCode).
89+
/// Example: `/api/v1/data?model=country&q=United` (searches name and isoCode)
90+
/// Example: `/api/v1/data?model=country&q=US` (searches name and isoCode)
9091
/// - Other parameters for countries will result in a 400 Bad Request.
9192
///
9293
/// - **Other Models (User, UserAppSettings, UserContentPreferences, AppConfig):**
@@ -162,7 +163,7 @@ Future<Response> _handleGet(
162163
final qValue = queryParams['q'];
163164
if (qValue != null && qValue.isNotEmpty) {
164165
specificQueryForClient['name_contains'] = qValue;
165-
// specificQueryForClient['iso_code_contains'] = qValue; // Removed
166+
specificQueryForClient['iso_code_contains'] = qValue; // Added back
166167
}
167168
default:
168169
// For other models, pass through all non-standard query params directly.
@@ -541,11 +542,11 @@ Model: `category`
541542
542543
Model: `country`
543544
544-
20. Filter by text query `q` for countries (name only):
545+
20. Filter by text query `q` for countries (name and iso_code):
545546
- URL: `/api/v1/data?model=country&q=United`
546547
- Expected: Countries where "United" appears in the name.
547548
548-
21. Filter by text query `q` for countries (name only, to match "US" if a country name contains "US"):
549+
21. Filter by text query `q` for countries (name and iso_code):
549550
- URL: `/api/v1/data?model=country&q=US`
550551
- Expected: Country with name containing "US". (Note: This test's expectation might need adjustment if no country name contains "US" but its isoCode is "US". The current `q` logic for country only searches name).
551552

0 commit comments

Comments
 (0)