platform/data/profile-db
Classes
Section titled “Classes”ProfileDatabase
Section titled “ProfileDatabase”Defined in: app/src/platform/data/profile-db.ts:120
The profile database profile.db: history with full-text search, bookmarks and the list
of downloads. It runs
in the data service process, never in the browser process, because SQLite calls block.
Schema changes run as numbered migrations; before one runs on an existing database, a
copy is written next to it with VACUUM INTO. A database from a newer version is opened
read-only, so an older version never changes data it does not understand.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ProfileDatabase(
path,clock?):ProfileDatabase
Defined in: app/src/platform/data/profile-db.ts:130
Parameters
Section titled “Parameters”string
Path of profile.db, or :memory: in tests.
clock?
Section titled “clock?”() => number
Current time in milliseconds since 1970.
Returns
Section titled “Returns”Properties
Section titled “Properties”readOnly
Section titled “readOnly”
readonlyreadOnly:boolean
Defined in: app/src/platform/data/profile-db.ts:124
Whether the database belongs to a newer version and must not be written.
Methods
Section titled “Methods”addBookmark()
Section titled “addBookmark()”addBookmark(
parent,title,url?):number
Defined in: app/src/platform/data/profile-db.ts:298
Adds a bookmark or a folder at the end of a folder.
Parameters
Section titled “Parameters”parent
Section titled “parent”number
The folder.
string
Its title.
string
The address of a bookmark; omitted for a folder.
Returns
Section titled “Returns”number
The new id.
addDownload()
Section titled “addDownload()”addDownload(
url,path,total):number
Defined in: app/src/platform/data/profile-db.ts:429
Adds a download to the list, which keeps the most recent ones.
Parameters
Section titled “Parameters”string
The address it comes from.
string
The file it is saved to.
number
Its size in bytes, or 0 while unknown.
Returns
Section titled “Returns”number
Its id.
addVisit()
Section titled “addVisit()”addVisit(
url,title?):void
Defined in: app/src/platform/data/profile-db.ts:163
Records a visit of a page.
Parameters
Section titled “Parameters”string
The page’s address.
title?
Section titled “title?”string = ''
Its title, if known yet.
Returns
Section titled “Returns”void
bookmarkList()
Section titled “bookmarkList()”bookmarkList():
BookmarkRow[]
Defined in: app/src/platform/data/profile-db.ts:312
Every bookmark and folder in display order: the two root folders first, then the contents of each folder in their order. Roots have no parent, folders no address.
Returns
Section titled “Returns”bookmarks()
Section titled “bookmarks()”bookmarks():
BookmarkNode[]
Defined in: app/src/platform/data/profile-db.ts:256
The bookmarks: the bookmarks bar and the other bookmarks, with their folders.
Returns
Section titled “Returns”bookmarkUrls()
Section titled “bookmarkUrls()”bookmarkUrls():
string[]
Defined in: app/src/platform/data/profile-db.ts:325
The distinct addresses of all bookmarks.
Returns
Section titled “Returns”string[]
clearHistory()
Section titled “clearHistory()”clearHistory():
void
Defined in: app/src/platform/data/profile-db.ts:227
Removes the whole history.
Returns
Section titled “Returns”void
close()
Section titled “close()”close():
void
Defined in: app/src/platform/data/profile-db.ts:504
Closes the database.
Returns
Section titled “Returns”void
deleteHistory()
Section titled “deleteHistory()”deleteHistory(
ids):void
Defined in: app/src/platform/data/profile-db.ts:220
Removes pages from the history.
Parameters
Section titled “Parameters”readonly number[]
The pages.
Returns
Section titled “Returns”void
downloads()
Section titled “downloads()”downloads(
limit?):DownloadEntry[]
Defined in: app/src/platform/data/profile-db.ts:467
The most recent downloads, newest first. Downloads that were still running when the browser stopped are interrupted.
Parameters
Section titled “Parameters”limit?
Section titled “limit?”number = 100
Most downloads to return.
Returns
Section titled “Returns”history()
Section titled “history()”history(
query,limit?,before?):HistoryEntry[]
Defined in: app/src/platform/data/profile-db.ts:190
Pages of the history, newest first, optionally matching search terms.
Parameters
Section titled “Parameters”string
Words that the title or address must contain; empty for all pages.
limit?
Section titled “limit?”number = 100
The most pages to return.
before?
Section titled “before?”number = Number.MAX_SAFE_INTEGER
Only pages visited before this time.
Returns
Section titled “Returns”importBookmarks()
Section titled “importBookmarks()”importBookmarks(
folderTitle,tree,source):number
Defined in: app/src/platform/data/profile-db.ts:389
Imports another browser’s bookmarks into a new folder of the other bookmarks. The folder of an earlier import from the same source is replaced, so importing again adds nothing.
Parameters
Section titled “Parameters”folderTitle
Section titled “folderTitle”string
Title of the new folder, such as “Imported from Chrome”.
readonly ImportedBookmark[]
The bookmarks and folders.
source
Section titled “source”string
Identifies where the bookmarks come from, such as a browser profile.
Returns
Section titled “Returns”number
How many bookmarks were imported.
importHistory()
Section titled “importHistory()”importHistory(
visits):number
Defined in: app/src/platform/data/profile-db.ts:238
Adds pages of another browser’s history; pages that exist keep the newer visit and the higher count of visits, so importing the same history again changes nothing.
Parameters
Section titled “Parameters”visits
Section titled “visits”readonly ImportedVisit[]
The pages.
Returns
Section titled “Returns”number
How many pages were new.
interruptDownloads()
Section titled “interruptDownloads()”interruptDownloads():
void
Defined in: app/src/platform/data/profile-db.ts:486
Marks the downloads that were still running when the browser stopped as interrupted.
Returns
Section titled “Returns”void
removeBookmark()
Section titled “removeBookmark()”removeBookmark(
id):void
Defined in: app/src/platform/data/profile-db.ts:366
Removes a bookmark or a folder with everything in it. The root folders stay.
Parameters
Section titled “Parameters”number
The bookmark or folder.
Returns
Section titled “Returns”void
removeBookmarkUrl()
Section titled “removeBookmarkUrl()”removeBookmarkUrl(
url):void
Defined in: app/src/platform/data/profile-db.ts:376
Removes every bookmark of an address, for the star in the address bar.
Parameters
Section titled “Parameters”string
The address.
Returns
Section titled “Returns”void
removeDownloads()
Section titled “removeDownloads()”removeDownloads(
ids):void
Defined in: app/src/platform/data/profile-db.ts:495
Removes downloads from the list; their files stay.
Parameters
Section titled “Parameters”readonly number[]
The downloads.
Returns
Section titled “Returns”void
setTitle()
Section titled “setTitle()”setTitle(
url,title):void
Defined in: app/src/platform/data/profile-db.ts:179
Updates the title of a page in the history.
Parameters
Section titled “Parameters”string
The page’s address.
string
Its new title.
Returns
Section titled “Returns”void
updateBookmark()
Section titled “updateBookmark()”updateBookmark(
id,title,url?,parent?):void
Defined in: app/src/platform/data/profile-db.ts:341
Renames a bookmark or a folder, changes the address of a bookmark, and moves either to the end of another folder. The root folders stay as they are, and a folder never moves into itself or one of its own folders.
Parameters
Section titled “Parameters”number
The bookmark or folder.
string
Its new title.
string
The new address of a bookmark; ignored for a folder.
parent?
Section titled “parent?”number
The folder to move it to; omitted to keep it where it is.
Returns
Section titled “Returns”void
updateDownload()
Section titled “updateDownload()”updateDownload(
id,received,total,state):void
Defined in: app/src/platform/data/profile-db.ts:455
Records how far a download got and where it stands.
Parameters
Section titled “Parameters”number
The download.
received
Section titled “received”number
The bytes received.
number
Its size in bytes, or 0 while unknown.
Where it stands.
Returns
Section titled “Returns”void
Interfaces
Section titled “Interfaces”BookmarkNode
Section titled “BookmarkNode”Defined in: app/src/platform/data/profile-db.ts:16
A bookmark or a folder of bookmarks.
Properties
Section titled “Properties”children?
Section titled “children?”
readonlyoptionalchildren?: readonlyBookmarkNode[]
Defined in: app/src/platform/data/profile-db.ts:21
readonlyid:number
Defined in: app/src/platform/data/profile-db.ts:17
readonlytitle:string
Defined in: app/src/platform/data/profile-db.ts:18
readonlyoptionalurl?:string
Defined in: app/src/platform/data/profile-db.ts:20
The address of a bookmark; undefined for a folder.
BookmarkRow
Section titled “BookmarkRow”Defined in: app/src/platform/data/profile-db.ts:25
A bookmark or folder as the bookmarks page lists it.
Properties
Section titled “Properties”
readonlyid:number
Defined in: app/src/platform/data/profile-db.ts:26
parentId
Section titled “parentId”
readonlyparentId:number|null
Defined in: app/src/platform/data/profile-db.ts:28
The folder it is in; null for the two root folders.
readonlytitle:string
Defined in: app/src/platform/data/profile-db.ts:29
readonlyurl:string|null
Defined in: app/src/platform/data/profile-db.ts:31
The address of a bookmark; null for a folder.
HistoryEntry
Section titled “HistoryEntry”Defined in: app/src/platform/data/profile-db.ts:6
A page in the history, with its most recent visit.
Properties
Section titled “Properties”
readonlyid:number
Defined in: app/src/platform/data/profile-db.ts:7
lastVisit
Section titled “lastVisit”
readonlylastVisit:number
Defined in: app/src/platform/data/profile-db.ts:12
Milliseconds since 1970 of the most recent visit.
readonlytitle:string
Defined in: app/src/platform/data/profile-db.ts:9
readonlyurl:string
Defined in: app/src/platform/data/profile-db.ts:8
visitCount
Section titled “visitCount”
readonlyvisitCount:number
Defined in: app/src/platform/data/profile-db.ts:10
ImportedBookmark
Section titled “ImportedBookmark”Defined in: app/src/platform/data/profile-db.ts:35
A bookmark or folder to import, as another browser stores it.
Properties
Section titled “Properties”children?
Section titled “children?”
readonlyoptionalchildren?: readonlyImportedBookmark[]
Defined in: app/src/platform/data/profile-db.ts:38
readonlytitle:string
Defined in: app/src/platform/data/profile-db.ts:36
readonlyoptionalurl?:string
Defined in: app/src/platform/data/profile-db.ts:37
ImportedVisit
Section titled “ImportedVisit”Defined in: app/src/platform/data/profile-db.ts:42
A page of another browser’s history to import.
Properties
Section titled “Properties”lastVisit
Section titled “lastVisit”
readonlylastVisit:number
Defined in: app/src/platform/data/profile-db.ts:46
readonlytitle:string
Defined in: app/src/platform/data/profile-db.ts:44
readonlyurl:string
Defined in: app/src/platform/data/profile-db.ts:43
visitCount
Section titled “visitCount”
readonlyvisitCount:number
Defined in: app/src/platform/data/profile-db.ts:45
Variables
Section titled “Variables”profileSchemaVersion
Section titled “profileSchemaVersion”
constprofileSchemaVersion:number=migrations.length
Defined in: app/src/platform/data/profile-db.ts:110
The schema version that this build writes.
References
Section titled “References”bookmarkRoots
Section titled “bookmarkRoots”Re-exports bookmarkRoots