* Open an existing database. * * `deferIndexRecovery` leaves the secondary indexes an interrupted bulk load * dropped for recoverIndexesOffThread instead of rebuilding them * here. Rebuilding one scans and sorts its whole table: on a large index * that is minutes of synchronou
(dbPath: string, options: { readOnly?: boolean; deferIndexRecovery?: boolean } = {})
| 195 | * it starts (#1887). Reads stay correct meanwhile, only slower. |
| 196 | */ |
| 197 | static open(dbPath: string, options: { readOnly?: boolean; deferIndexRecovery?: boolean } = {}): DatabaseConnection { |
| 198 | if (!fs.existsSync(dbPath)) { |
| 199 | throw new Error(`Database not found: ${dbPath}`); |
| 200 | } |
| 201 | |
| 202 | const { db, backend } = createDatabase(dbPath, options); |
| 203 | return withOpenFailures(db, dbPath, () => DatabaseConnection.openOn(db, backend, dbPath, options)); |
| 204 | } |
| 205 | |
| 206 | /** The rest of {@link open}: configure the connection, then migrate and repair a writable one. */ |
| 207 | private static openOn( |
nothing calls this directly
no test coverage detected