docs(dev): update database structure

This commit is contained in:
Elian Doran
2025-11-04 22:53:42 +02:00
parent 421c1f257e
commit 3359ff5470
9 changed files with 157 additions and 60 deletions

View File

@@ -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",

View File

@@ -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. |

View File

@@ -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`). |

View File

@@ -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. |

View File

@@ -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"`). |

View File

@@ -383,7 +383,7 @@ for (const blob of orphanedBlobs) {
**Process:**
```sh
```
# Check for vulnerabilities
npm audit
@@ -424,7 +424,7 @@ npm audit fix --force
**pnpm Patches:**
```sh
```
# Create patch
pnpm patch @ckeditor/ckeditor5

View File

@@ -9,7 +9,7 @@ Trilium implements a **bidirectional synchronization system** that allows users
## Sync Architecture
```mermaid
```
graph TB
Desktop1[Desktop 1<br/>Client]
Desktop2[Desktop 2<br/>Client]

View File

@@ -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.

View File

@@ -25,56 +25,35 @@
{
"type": "relation",
"name": "internalLink",
"value": "BFs8mudNFgCS",
"value": "gh7bpGYxajRS",
"isInheritable": false,
"position": 20
},
{
"type": "relation",
"name": "internalLink",
"value": "BFs8mudNFgCS",
"isInheritable": false,
"position": 30
},
{
"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",
"isInheritable": false,
"position": 30
"position": 40
},
{
"type": "relation",
"name": "internalLink",
"value": "poXkQfguuA0U",
"isInheritable": false,
"position": 40
},
{
"type": "relation",
"name": "internalLink",
"value": "WOcw2SLH6tbX",
"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",