Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(dev): update database structure
Elian Doran3359ff547003
diff --git a/docs/Developer Guide/!!!meta.json b/docs/Developer Guide/!!!meta.jsonindex 397bdcab44..a6c26628d7 100644--- a/docs/Developer Guide/!!!meta.json+++ b/docs/Developer Guide/!!!meta.json@@ -15,6 +15,20 @@"type": "text","mime": "text/html","attributes": [+ {+ "type": "relation",+ "name": "internalLink",+ "value": "T2W7WCZrYZBU",+ "isInheritable": false,+ "position": 10+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "cxfTSHIUQtt2",+ "isInheritable": false,+ "position": 20+ },{"type": "label","name": "label:shareAlias",@@ -35,20 +49,6 @@"value": "developer-guide","isInheritable": false,"position": 30- },- {- "type": "relation",- "name": "internalLink",- "value": "T2W7WCZrYZBU",- "isInheritable": false,- "position": 40- },- {- "type": "relation",- "name": "internalLink",- "value": "cxfTSHIUQtt2",- "isInheritable": false,- "position": 50}],"format": "markdown",@@ -245,6 +245,13 @@"value": "database","isInheritable": false,"position": 20+ },+ {+ "type": "label",+ "name": "iconClass",+ "value": "bx bx-data",+ "isInheritable": false,+ "position": 30}],"format": "markdown",@@ -590,13 +597,6 @@"type": "text","mime": "text/html","attributes": [- {- "type": "relation",- "name": "internalLink",- "value": "VIcWnKGs0sMh",- "isInheritable": false,- "position": 10- },{"type": "relation","name": "internalLink",@@ -624,6 +624,13 @@"value": "notes","isInheritable": false,"position": 40+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "VIcWnKGs0sMh",+ "isInheritable": false,+ "position": 50}],"format": "markdown",@@ -765,6 +772,71 @@"format": "markdown","dataFileName": "revisions.md","attachments": []+ },+ {+ "isClone": false,+ "noteId": "6DG1au6rgOTl",+ "notePath": [+ "jdjRLhLV3TtI",+ "MhwWMgxwDTZL",+ "pRZhrVIGCbMu",+ "vNMojjUN76jc",+ "6DG1au6rgOTl"+ ],+ "title": "sessions",+ "notePosition": 66,+ "prefix": null,+ "isExpanded": false,+ "type": "text",+ "mime": "text/html",+ "attributes": [+ {+ "type": "label",+ "name": "iconClass",+ "value": "bx bx-table",+ "isInheritable": false,+ "position": 20+ },+ {+ "type": "label",+ "name": "shareAlias",+ "value": "sessions",+ "isInheritable": false,+ "position": 30+ }+ ],+ "format": "markdown",+ "dataFileName": "sessions.md",+ "attachments": []+ },+ {+ "isClone": false,+ "noteId": "zWY2LKmas9os",+ "notePath": [+ "jdjRLhLV3TtI",+ "MhwWMgxwDTZL",+ "pRZhrVIGCbMu",+ "vNMojjUN76jc",+ "zWY2LKmas9os"+ ],+ "title": "user_data",+ "notePosition": 76,+ "prefix": null,+ "isExpanded": false,+ "type": "text",+ "mime": "text/html",+ "attributes": [+ {+ "type": "label",+ "name": "iconClass",+ "value": "bx bx-table",+ "isInheritable": false,+ "position": 20+ }+ ],+ "format": "markdown",+ "dataFileName": "user_data.md",+ "attachments": []}]}@@ -817,7 +889,7 @@"name": "internalLink","value": "Jg7clqogFOyD","isInheritable": false,- "position": 20+ "position": 10},{"type": "label",diff --git a/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/notes.md b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/notes.mdindex 19cb4a3223..108ea8b267 100644--- a/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/notes.md+++ b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/notes.md@@ -6,10 +6,10 @@| `isProtected` | Integer | Non-null | 0 | `1` if the entity is [protected](../../../Concepts/Protected%20entities.md), `0` otherwise. || `type` | Text | Non-null | `"text"` | The type of note (i.e. `text`, `file`, `code`, `relationMap`, `mermaid`, `canvas`). || `mime` | Text | Non-null | `"text/html"` | The MIME type of the note (e.g. `text/html`).. Note that it can be an empty string in some circumstances, but not null. |+| `blobId` | Text | Nullable | `null` | The corresponding ID from <a class="reference-link" href="blobs.md">blobs</a>. Although it can theoretically be `NULL`, haven't found any such note yet. || `isDeleted` | Integer | Nullable | 0 | `1` if the entity is [deleted](../../../Concepts/Deleted%20notes.md), `0` otherwise. || `deleteId` | Text | Non-null | `null` | || `dateCreated` | Text | Non-null | | Localized creation date (e.g. `2023-11-08 18:43:44.204+0200`) || `dateModified` | Text | Non-null | | Localized modification date (e.g. `2023-11-08 18:43:44.204+0200`) || `utcDateCreated` | Text | Non-null | | Creation date in UTC format (e.g. `2023-11-08 16:43:44.204Z`) |-| `utcDateModified` | Text | Non-null | | Modification date in UTC format (e.g. `2023-11-08 16:43:44.204Z`) |-| `blobId` | Text | Nullable | `null` | The corresponding ID from <a class="reference-link" href="blobs.md">blobs</a>. Although it can theoretically be `NULL`, haven't found any such note yet. |\ No newline at end of file+| `utcDateModified` | Text | Non-null | | Modification date in UTC format (e.g. `2023-11-08 16:43:44.204Z`) |\ No newline at end of filediff --git a/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/revisions.md b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/revisions.mdindex fef9ed1eda..faae5421cb 100644--- a/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/revisions.md+++ b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/revisions.md@@ -1,7 +1,7 @@# revisions| Column Name | Data Type | Nullity | Default value | Description || --- | --- | --- | --- | --- |-| `revisionId` | TextText | Non-null | | Unique ID of the revision (e.g. `0GjgUqnEudI8`). |+| `revisionId` | Text | Non-null | | Unique ID of the revision (e.g. `0GjgUqnEudI8`). || `noteId` | Text | Non-null | | ID of the [note](notes.md) this revision belongs to. || `type` | Text | Non-null | `""` | The type of note (i.e. `text`, `file`, `code`, `relationMap`, `mermaid`, `canvas`). || `mime` | Text | Non-null | `""` | The MIME type of the note (e.g. `text/html`). |diff --git a/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/sessions.md b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/sessions.mdnew file mode 100644index 0000000000..4562361522--- /dev/null+++ b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/sessions.md@@ -0,0 +1,8 @@+# sessions+Contains user sessions for authentication purposes. The table is almost a direct mapping of the information that `express-session` requires.++| Column Name | Data Type | Nullity | Default value | Description |+| --- | --- | --- | --- | --- |+| `id` | Text | Non-null | | Unique, non-sequential ID of the session, directly as indicated by `express-session` |+| `data` | Text | Non-null | | The session information, in stringified JSON format. |+| `expires` | Integer | Non-null | | The expiration date of the session, extracted from the session information. Used to rapidly clean up expired sessions. |\ No newline at end of filediff --git a/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/user_data.md b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/user_data.mdnew file mode 100644index 0000000000..3b27ee30fe--- /dev/null+++ b/docs/Developer Guide/Developer Guide/Architecture/Database/Database structure/user_data.md@@ -0,0 +1,17 @@+# user_data+Contains the user information for two-factor authentication. This table is **not** used for multi-user.++Relevant files:++* `apps/server/src/services/encryption/open_id_encryption.ts`++| Column Name | Data Type | Nullity | Default value | Description |+| --- | --- | --- | --- | --- |+| `tmpID` | Integer | | | A sequential ID of the user. Since only one user is supported by Trilium, this value is always zero. |+| `username` | Text | | | The user name as returned from the OAuth operation. |+| `email` | Text | | | The email as returned from the OAuth operation. |+| `userIDEncryptedDataKey` | Text | | | An encrypted hash of the user subject identifier from the OAuth operation. |+| `userIDVerificationHash` | Text | | | A salted hash of the subject identifier from the OAuth operation. |+| `salt` | Text | | | The verification salt. |+| `derivedKey` | Text | | | A random secure token. |+| `isSetup` | Text | | `"false"` | Indicates that the user has been saved (`"true"`). |\ No newline at end of filediff --git a/docs/Developer Guide/Developer Guide/Architecture/Security.md b/docs/Developer Guide/Developer Guide/Architecture/Security.mdindex 61fdc73776..f1ef4da771 100644--- a/docs/Developer Guide/Developer Guide/Architecture/Security.md+++ b/docs/Developer Guide/Developer Guide/Architecture/Security.md@@ -383,7 +383,7 @@ for (const blob of orphanedBlobs) {**Process:**-```sh+```# Check for vulnerabilitiesnpm audit@@ -424,7 +424,7 @@ npm audit fix --force**pnpm Patches:**-```sh+```# Create patchpnpm patch @ckeditor/ckeditor5diff --git a/docs/Developer Guide/Developer Guide/Concepts/Synchronisation.md b/docs/Developer Guide/Developer Guide/Concepts/Synchronisation.mdindex f97bd3c4eb..45a520cb68 100644--- a/docs/Developer Guide/Developer Guide/Concepts/Synchronisation.md+++ b/docs/Developer Guide/Developer Guide/Concepts/Synchronisation.md@@ -9,7 +9,7 @@ Trilium implements a **bidirectional synchronization system** that allows users## Sync Architecture-```mermaid+```graph TBDesktop1[Desktop 1<br/>Client]Desktop2[Desktop 2<br/>Client]diff --git a/docs/Developer Guide/Developer Guide/Documentation.md b/docs/Developer Guide/Developer Guide/Documentation.mdindex 4da87601a7..9d3bb1f071 100644--- a/docs/Developer Guide/Developer Guide/Documentation.md+++ b/docs/Developer Guide/Developer Guide/Documentation.md@@ -1,5 +1,5 @@# Documentation-There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/45okJ9xpVO32/Documentation_image.png" width="205" height="162">+There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/OrRMknW5zkc4/Documentation_image.png" width="205" height="162">* The _User Guide_ represents the user-facing documentation. This documentation can be browsed by users directly from within Trilium, by pressing <kbd>F1</kbd>.* The _Developer's Guide_ represents a set of Markdown documents that present the internals of Trilium, for developers.diff --git a/docs/User Guide/!!!meta.json b/docs/User Guide/!!!meta.jsonindex 86ddd95898..c0be591162 100644--- a/docs/User Guide/!!!meta.json+++ b/docs/User Guide/!!!meta.json@@ -25,56 +25,35 @@{"type": "relation","name": "internalLink",- "value": "BFs8mudNFgCS",+ "value": "gh7bpGYxajRS","isInheritable": false,"position": 20},{"type": "relation","name": "internalLink",- "value": "GTwFsgaA0lCt",- "isInheritable": false,- "position": 30- },- {- "type": "label",- "name": "shareAlias",- "value": "user-guide",- "isInheritable": false,- "position": 10- },- {- "type": "label",- "name": "label:shareAlias",- "value": "promoted,alias=Slug,single,text",- "isInheritable": true,- "position": 20- },- {- "type": "label",- "name": "iconClass",- "value": "bx bx-help-circle",+ "value": "BFs8mudNFgCS","isInheritable": false,"position": 30},{"type": "relation","name": "internalLink",- "value": "poXkQfguuA0U",+ "value": "GTwFsgaA0lCt","isInheritable": false,"position": 40},{"type": "relation","name": "internalLink",- "value": "WOcw2SLH6tbX",+ "value": "poXkQfguuA0U","isInheritable": false,"position": 50},{"type": "relation","name": "internalLink",- "value": "gh7bpGYxajRS",+ "value": "WOcw2SLH6tbX","isInheritable": false,"position": 60},@@ -98,6 +77,27 @@"value": "9qPsTWBorUhQ","isInheritable": false,"position": 90+ },+ {+ "type": "label",+ "name": "shareAlias",+ "value": "user-guide",+ "isInheritable": false,+ "position": 10+ },+ {+ "type": "label",+ "name": "label:shareAlias",+ "value": "promoted,alias=Slug,single,text",+ "isInheritable": true,+ "position": 20+ },+ {+ "type": "label",+ "name": "iconClass",+ "value": "bx bx-help-circle",+ "isInheritable": false,+ "position": 30}],"format": "markdown",