fix: adding path column names to tags and tasks

This commit is contained in:
Kacper Kula 2025-02-05 17:17:15 +00:00
parent 06d10c576b
commit 5cf7f247de
8 changed files with 29 additions and 21 deletions

View file

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

View file

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

View file

@ -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).
See full breakdown in [Data Sources: Vault Data](./data-sources/vault-data.md).

View file

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

View file

@ -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": {

View file

@ -10,7 +10,7 @@ export class TagsFileSyncTable extends AFileSyncTable {
await this.onFileCreate(file)
}
async onFileDelete(path: string): Promise<void> {
await this.db.deleteData('tags', [{ fileId: path }], 'fileId')
await this.db.deleteData('tags', [{ path }], 'path')
}
async onFileCreate(file: TFile): Promise<void> {
@ -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<void> {
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])
))

View file

@ -10,7 +10,7 @@ export class TasksFileSyncTable extends AFileSyncTable {
await this.onFileCreate(file)
}
async onFileDelete(path: string): Promise<void> {
await this.db.deleteData('tasks', [{ filePath: path }], 'filePath')
await this.db.deleteData('tasks', [{ path: path }], 'path')
}
async onFileCreate(file: TFile): Promise<void> {
@ -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<void> {
await this.db.createTableNoTypes('tasks', ['task', 'completed', 'filePath'])
await this.db.createTableNoTypes('tasks', ['task', 'completed', 'filePath', 'path'])
// Indexes
const toIndex = ['filePath']

View file

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