Bihar Police Notebook persists all documents locally in the browser using IndexedDB. There is no server — every letter and diary is stored on the device that opened the editor. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/arverma/Bihar-Police-Notebook/llms.txt
Use this file to discover all available pages before exploring further.
editor/js/store.js module is the single source of truth for reads, writes, soft-deletes, and Drive sync metadata. A separate prefs.js module handles lightweight UI and auth preferences via localStorage.
Database Schema
| Property | Value |
|---|---|
| Database name | bp-writing-tool |
| Version | 2 |
| Object stores | letter, diary |
| Key path | id (auto-increment integer) |
| Indexes | filename (non-unique), uuid (unique) |
uuid index and ran a migration (migrateAssignUuids) that backfills stable UUIDs onto any existing rows created before the Drive sync feature was introduced.
Document Fields
Auto-increment integer primary key assigned by IndexedDB.
Display name shown in the History sidebar. Defaults to the formatted creation date (e.g.
"12 Jun 2024").For letters: raw text or Quill delta HTML. For diaries: JSON-serialised
{ header, pages } object.Identifies which object store the document lives in.
Stable identifier used to match local documents with their Drive counterparts. Generated with
crypto.randomUUID() where available, or a bp-{timestamp}-{random} fallback.ISO 8601 timestamp set when the document is first created. Never updated on subsequent saves.
ISO 8601 timestamp updated on every
saveDocumentById call.Google Drive file ID of the corresponding
{uuid}.json file, or null if never synced.ISO 8601 timestamp of the last successful Drive push, or
null.Error message from the most recent failed sync attempt, cleared to
null on a successful push.ISO 8601 timestamp set by soft-delete.
null for live documents. Used as a Drive tombstone until the deletion is confirmed uploaded.Read Functions
The object store to query.
getDocuments(type)
deletedAt set) are filtered out.
getDocumentsIncludingDeleted(type?)
type is omitted, queries both letter and diary stores and merges the results. Used by the Drive sync module to enumerate all pending operations.
getDocumentById(type, id)
id. Returns null if the row does not exist. Called on startup to restore the last-active document.
getDocumentByUuid(uuid, type?)
uuid. Searches across both stores when type is omitted. Used during Drive pull-and-merge to match remote JSON files to local rows.
previewText(doc)
"FIR {fir_number} · Case {case_diary_no}". For letters, strips HTML tags and returns up to 40 characters of plain text.
Write Functions
saveDocumentById(type, doc)
doc.id is provided and a matching row exists, it updates filename, content, updated_at, and clears syncError. When no matching row is found (or doc.id is null), it inserts a new row. Returns the document’s integer id.
On update,
syncError is cleared but syncedAt is not updated — the document is now dirty and needsBackup will return true until the next Drive push.saveDocument(type, filename, content)
saveDocumentById that always inserts a new row (passes id: null). Intended for programmatic document creation where no existing ID is known.
upsertFromRemote(remote)
updated_at. If a local document with the same uuid exists and the remote updated_at is newer, the local row is overwritten. If no local match exists, a new row is inserted. Sets syncedAt to the remote’s updated_at so the document is not immediately re-uploaded.
Delete Functions
softDeleteDocumentById(type, id)
deletedAt and updated_at on the row without physically removing it. The tombstone allows Drive sync to propagate the deletion before the row is purged. Returns null if the document was already deleted or does not exist.
softDeleteDocument(type, filename)
filename index lookup. Targets the first live document that matches. Used in legacy code paths and when no numeric ID is available.
hardDeleteById(type, id)
Sync Metadata Functions
needsBackup(doc)
true when a document needs a Drive upload. A document needs backup if it has no driveFileId, has never been synced (syncedAt is null), or its updated_at (or deletedAt) timestamp is newer than syncedAt.
backupStatus(doc)
'error' when syncError is set and needsBackup is true, 'pending' when needsBackup is true without an error, and 'synced' otherwise.
markSynced(type, id, fields)
content or updated_at. Called by drive-sync.js after a successful or failed upload.
listPendingSync(type?)
needsBackup is true. Queries both stores when type is omitted. Used by pushPending() in drive-sync.js.
clearAllDriveFileIds()
driveFileId on every row in both object stores. Called when the Drive backup folder is found to have been deleted — clearing the IDs forces the next pushPending to re-create all remote files from scratch.
Preferences (localStorage)
UI flags, auth state, and user preferences are stored separately inlocalStorage via editor/js/prefs.js, not in IndexedDB. Keys follow the bpnt.* namespace convention:
| Key | Meaning |
|---|---|
bpnt.drive.connected | true when a Drive session has been authorised |
bpnt.drive.email | Connected Google account email address |
bpnt.drive.folderId | Cached ID of the backup folder in My Drive |
bpnt.dictationLang | Last-used dictation language (hi-IN or en-IN) |
bpnt.cloudConsent.{lang} | true when the user has consented to cloud speech for a language |