also looking at this
fix(orm): make createModel models findable, so relations read the declared table
#1104
3 files
+244
-3
| @@ -41,7 +41,7 @@ | ||
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | 43 | import { createBrowserModel, isBrowser, type BrowserModelDefinition } from './browser' |
| 44 | import { createModel, type ModelDefinition as OrmModelDefinition } from './orm' | |
| 44 | import { clearLocalModels, createModel, type ModelDefinition as OrmModelDefinition } from './orm' | |
| 45 | 45 | |
| 46 | 46 | // Re-export the browser model types for convenience |
| 47 | 47 | export type { BrowserModelDefinition as ModelDefinition } |
| @@ -119,9 +119,14 @@ export function hasModel(name: string): boolean { | ||
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Clear all registered models. Primarily useful for testing. |
| 122 | * | |
| 123 | * Also drops the models `createModel` registered internally, and the memoized | |
| 124 | * relation resolutions derived from them. Leaving either behind lets a stale | |
| 125 | * resolution from one test file decide a relation's table in the next. | |
| 122 | 126 | */ |
| 123 | 127 | export function clearModelRegistry(): void { |
| 124 | 128 | modelRegistry.clear() |
| 129 | clearLocalModels() | |
| 125 | 130 | } |
| 126 | 131 | |
| 127 | 132 | /** |