* Get the Drizzle DB instance. Kicks off lazy init on first call. * If the async init hasn't completed yet, returns a lazy Proxy that * records the Drizzle chain (select/from/where/etc.) and replays it * once the DB driver finishes loading. Since callers always `await` * the final result
()
| 157 | * the final result, the proxy is transparent. |
| 158 | */ |
| 159 | function getDb(): LibSQLDatabase<T> { |
| 160 | if (_db) return _db; |
| 161 | startInit(); |
| 162 | if (_db) return _db; |
| 163 | |
| 164 | return createLazyProxy(_dbReady!, []) as LibSQLDatabase<T>; |
| 165 | } |
| 166 | |
| 167 | return getDb; |
| 168 | } |
no test coverage detected