(entity: StoreEntity)
| 153 | }); |
| 154 | |
| 155 | function assertEntityNotBreakingUniqueIndex(entity: StoreEntity) { |
| 156 | if (!definition.config.uniqueProps) return; |
| 157 | |
| 158 | for (const uniquePropName of definition.config.uniqueProps) { |
| 159 | const index = store.getPropIndex(uniquePropName); |
| 160 | const propValue = entity[uniquePropName] as unknown as IndexFindInput< |
| 161 | Data, |
| 162 | View, |
| 163 | keyof Data |
| 164 | >; |
| 165 | const existingEntities = index.find(propValue); |
| 166 | |
| 167 | if (existingEntities.length > 0) { |
| 168 | throw new Error( |
| 169 | `Entity "${ |
| 170 | definition.config.name |
| 171 | }" with unique property "${uniquePropName.toString()}"="${propValue?.toString()}" already exists` |
| 172 | ); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | function updateEntityIndexes( |
| 178 | entity: StoreEntity, |
no test coverage detected