()
| 125 | } |
| 126 | |
| 127 | export async function getDB(): Promise<IDatabase> { |
| 128 | if (db) return db; |
| 129 | |
| 130 | if (!dbLoadPromise) { |
| 131 | dbLoadPromise = (async () => { |
| 132 | const platform = getPlatformService(); |
| 133 | const loadedDb = await platform.loadDatabase(await getDatabaseLocation(DB_FILENAME)); |
| 134 | await configureDatabaseConnection(loadedDb); |
| 135 | db = loadedDb; |
| 136 | return loadedDb; |
| 137 | })().finally(() => { |
| 138 | dbLoadPromise = null; |
| 139 | }); |
| 140 | } |
| 141 | |
| 142 | return dbLoadPromise; |
| 143 | } |
| 144 | |
| 145 | /** Get or lazily open the local database (readany_local.db) */ |
| 146 | export async function getLocalDB(): Promise<IDatabase> { |
no test coverage detected