diff --git a/CHANGELOG.md b/CHANGELOG.md index 39fb5a1..ece16a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.24.1 (2025-02-05) +- Added `path` columns to `tags` and `tasks` tables. Thanks to that you can use `NATURAL JOIN`s now to connect join them. + # 0.24.0 (2025-02-05) - Better column names! Now non-latin characters are being romanised so you can access your properties (and other column names) easier: geändert becomes geandert, 类别 becomes lei_bie, ノートタイプ becomes nototaipu, etc. diff --git a/docs/data-sources/vault-data.md b/docs/data-sources/vault-data.md index 86cd18a..4e618df 100644 --- a/docs/data-sources/vault-data.md +++ b/docs/data-sources/vault-data.md @@ -25,18 +25,20 @@ Files table consists of the following columns: ### `tags` table Tags table consists of the following columns: -| Column | Description | Introduced In | -| -------- | --------------------------------------------------- | ------------- | -| `tag` | Full tag, including `#` symbol. For example `#todo` | | -| `fileId` | Full path of the file the tag belongs to | | +| Column | Description | Introduced In | +| -------- | ------------------------------------------------------------------------------------------------------------------------ | ------------- | +| `tag` | Full tag, including `#` symbol. For example `#todo` | | +| `path` | Full path of the file the tag belongs to | 0.24.1 | +| `fileId` | (deprecated) same like `path`. Name changed for compatibility with other tables. Will get removed in the future versions | | ### `tasks` table Tasks table consists of the following columns: -| Column | Description | -| ----------- | ---------------------------------------- | -| `task` | Content of the task (text) | -| `completed` | 0 if not completed, 1 if completed | -| `filePath` | Full path of the file the tag belongs to | +| Column | Description | Introduced In | +| ----------- | ------------------------------------------------------------------------------------------------------------------------ | ------------- | +| `task` | Content of the task (text) | | +| `completed` | 0 if not completed, 1 if completed | | +| `path` | Full path of the file the tag belongs to | 0.24.1 | +| `filePath` | (deprecated) same like `path`. Name changed for compatibility with other tables. Will get removed in the future versions | | ### `links` table Table containing all the links between files. diff --git a/docs/query-vault-content.md b/docs/query-vault-content.md index 36d8c7a..ea5c9d4 100644 --- a/docs/query-vault-content.md +++ b/docs/query-vault-content.md @@ -1,6 +1,6 @@ # Query your Vault content -You can query your vault content using SQLSeal built-in tables `files` and `tags` and `tasks`. You can use them to query specific files in the fault based on Properties (Frontmatter) and associated tags. +You can query your vault content using SQLSeal built-in tables `files`, `tags`, `tasks` and `links`. You can use them to query specific files in the fault based on Properties (Frontmatter) and associated tags. ## Example: Get all files from the vault To get all files from the fault you can run the following query: @@ -22,8 +22,8 @@ The query above will return only files that have property `type` set to value `r Tags are kept in a separate table `tags`. To select all files that have specific tag, we can perform simple join. ```sqlseal -SELECT files.* FROM files JOIN tags ON files.id=tags.fileId WHERE tag = '#important' +SELECT files.* FROM files JOIN tags ON files.path=tags.path WHERE tag = '#important' ``` ## Table Structure -See full breakdown in [Data Sources: Vault Data](./data-sources/vault-data.md). \ No newline at end of file +See full breakdown in [Data Sources: Vault Data](./data-sources/vault-data.md). diff --git a/manifest.json b/manifest.json index 6983ac8..b22b6cf 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "sqlseal", "name": "SQLSeal", - "version": "0.24.0", + "version": "0.24.1", "minAppVersion": "0.15.0", "description": "Use SQL in your notes to query your vault files and CSV content.", "author": "hypersphere", diff --git a/package.json b/package.json index 167b042..c437e86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sqlseal", - "version": "0.24.0", + "version": "0.24.1", "description": "A plugin for Obsidian that allows you to run SQL queries on your notes.", "main": "main.js", "scripts": { diff --git a/src/vaultSync/tables/tagsTable.ts b/src/vaultSync/tables/tagsTable.ts index fa54152..b08d764 100644 --- a/src/vaultSync/tables/tagsTable.ts +++ b/src/vaultSync/tables/tagsTable.ts @@ -10,7 +10,7 @@ export class TagsFileSyncTable extends AFileSyncTable { await this.onFileCreate(file) } async onFileDelete(path: string): Promise { - await this.db.deleteData('tags', [{ fileId: path }], 'fileId') + await this.db.deleteData('tags', [{ path }], 'path') } async onFileCreate(file: TFile): Promise { @@ -29,15 +29,16 @@ export class TagsFileSyncTable extends AFileSyncTable { } return tags.map((t) => ({ tag: t, - fileId: file.path + fileId: file.path, + path: file.path })) } async onInit(): Promise { - await this.db.createTableNoTypes('tags', ['tag', 'fileId']) + await this.db.createTableNoTypes('tags', ['tag', 'fileId', 'path']) // Indexes - const toIndex = ['tag', 'fileId'] + const toIndex = ['tag', 'fileId', 'path'] await Promise.all(toIndex.map(column => this.db.createIndex(`tags_${column}_idx`, this.tableName, [column]) )) diff --git a/src/vaultSync/tables/tasksTable.ts b/src/vaultSync/tables/tasksTable.ts index 1492baa..3dd4280 100644 --- a/src/vaultSync/tables/tasksTable.ts +++ b/src/vaultSync/tables/tasksTable.ts @@ -10,7 +10,7 @@ export class TasksFileSyncTable extends AFileSyncTable { await this.onFileCreate(file) } async onFileDelete(path: string): Promise { - await this.db.deleteData('tasks', [{ filePath: path }], 'filePath') + await this.db.deleteData('tasks', [{ path: path }], 'path') } async onFileCreate(file: TFile): Promise { @@ -41,6 +41,7 @@ export class TasksFileSyncTable extends AFileSyncTable { ).trim(); return { filePath: file.path, + path: file.path, task: taskContent, completed: status ? 1 : 0 } @@ -48,7 +49,7 @@ export class TasksFileSyncTable extends AFileSyncTable { } async onInit(): Promise { - await this.db.createTableNoTypes('tasks', ['task', 'completed', 'filePath']) + await this.db.createTableNoTypes('tasks', ['task', 'completed', 'filePath', 'path']) // Indexes const toIndex = ['filePath'] diff --git a/versions.json b/versions.json index 771dddf..93abd1e 100644 --- a/versions.json +++ b/versions.json @@ -43,5 +43,6 @@ "0.23.0": "0.15.0", "0.23.1": "0.15.0", "0.23.2": "0.15.0", - "0.24.0": "0.15.0" + "0.24.0": "0.15.0", + "0.24.1": "0.15.0" } \ No newline at end of file