check
The check method reads every row and index entry of the committed database, and every page that holds them, and resolves when all of them are sound.
check(): Promise<void>Opening a database checks only its catalog, and each page and row is checked as a statement reads it, so rows that are never read, and whether each index still matches its table, are checked only here. The check takes time in proportion to the database, and statements from every Client of the same OPFS name wait while it runs. Call it outside a transaction.
TinyJoin cannot yet repair a database that fails its check.
Example
import {ClientError, create} from 'tinyjoin';
const db = await create('opfs://my-app-v1');
try {
await db.check();
console.log('Every row and index entry is sound.');
} catch (error) {
if (!(error instanceof ClientError)) {
throw error;
}
// Nothing repairs a database that fails its check, so the application
// restores its own backup into a new OPFS name.
console.error(error.code);
} finally {
await db.close();
}