( collectionId: string, collectionSize: number, fieldPath: Array<string>, )
| 134 | * Check collection size and suggest index if needed (dev mode) |
| 135 | */ |
| 136 | export function checkCollectionSizeForIndex( |
| 137 | collectionId: string, |
| 138 | collectionSize: number, |
| 139 | fieldPath: Array<string>, |
| 140 | ): void { |
| 141 | if (!isDevModeEnabled()) return |
| 142 | |
| 143 | if (collectionSize > devModeConfig.collectionSizeThreshold) { |
| 144 | emitIndexSuggestion({ |
| 145 | type: `collection-size`, |
| 146 | collectionId, |
| 147 | fieldPath, |
| 148 | message: `Collection has ${collectionSize} items. Queries on "${fieldPath.join(`.`)}" may benefit from an index.`, |
| 149 | collectionSize, |
| 150 | }) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Clear query pattern tracking (useful for tests) |
no test coverage detected