Skip to content

Commit d19ce2c

Browse files
committed
feat(database): add local ads collection seeding and indexing
- Implement seeding for local ads collection - Add index on 'adType' field for efficient querying - Include necessary imports and fixtures for local ads
1 parent c52d0be commit d19ce2c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ class DatabaseSeedingService {
4545
getId: (item) => item.id,
4646
toJson: (item) => item.toJson(),
4747
);
48+
await _seedCollection<LocalAd>(
49+
collectionName: 'local_ads',
50+
fixtureData: localAdsFixturesData,
51+
getId: (item) => (item as dynamic).id as String,
52+
// ignore: unnecessary_lambdas
53+
toJson: (item) => LocalAd.toJson(item),
54+
);
4855

4956
_log.info('Database seeding process completed.');
5057
}
@@ -131,6 +138,13 @@ class DatabaseSeedingService {
131138
.collection('countries')
132139
.createIndex(keys: {'name': 1}, name: 'countries_name_index');
133140

141+
/// Index for searching local ads by adType.
142+
/// This index supports efficient queries and filtering on the 'adType' field
143+
/// of local ad documents.
144+
await _db
145+
.collection('local_ads')
146+
.createIndex(keys: {'adType': 1}, name: 'local_ads_adType_index');
147+
134148
// --- TTL and Unique Indexes via runCommand ---
135149
// The following indexes are created using the generic `runCommand` because
136150
// they require specific options not exposed by the simpler `createIndex`

0 commit comments

Comments
 (0)