Skip to content

Commit 93d9a1d

Browse files
committed
feat(database): add index for app_reviews collection
- Add index on 'userId' field in app_reviews collection - Optimize fetching review record for a specific user - Ensure indexes for app_reviews collection are set up correctly
1 parent 01b34e3 commit 93d9a1d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@ class DatabaseSeedingService {
313313
});
314314
_log.info('Ensured indexes for "reports".');
315315

316+
// Indexes for the app_reviews collection
317+
await _db.runCommand({
318+
'createIndexes': 'app_reviews',
319+
'indexes': [
320+
{
321+
// Optimizes fetching the review record for a specific user.
322+
'key': {'userId': 1},
323+
'name': 'userId_index',
324+
},
325+
],
326+
});
327+
_log.info('Ensured indexes for "app_reviews".');
328+
316329
_log.info('Database indexes are set up correctly.');
317330
} on Exception catch (e, s) {
318331
_log.severe('Failed to create database indexes.', e, s);

0 commit comments

Comments
 (0)