From 7a4704c7432c72d84bdd332706ea32c9621a2910 Mon Sep 17 00:00:00 2001 From: Kelly Sizer Date: Tue, 18 Mar 2025 01:26:06 -0500 Subject: [PATCH 1/2] tags in frontmatter was being removed from file query results via a destructuring assignment. Removed this destructured assignment --- src/vaultSync/tables/filesTable.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vaultSync/tables/filesTable.ts b/src/vaultSync/tables/filesTable.ts index d34b06c..9e99a4d 100644 --- a/src/vaultSync/tables/filesTable.ts +++ b/src/vaultSync/tables/filesTable.ts @@ -17,7 +17,7 @@ const extractFrontmatterFromFile = (file: TFile, plugin: Plugin): Record) { +function fileData(file: TFile, { ...frontmatter }: Record) { return { ...frontmatter, id: file.path, @@ -89,4 +89,4 @@ export class FilesFileSyncTable extends AFileSyncTable { this.db.createIndex(`files_${column}_idx`, FILES_TABLE_NAME, [column]) )) } -} \ No newline at end of file +} From 07f729ffc573106ef25ab8777c2ac595900d8f40 Mon Sep 17 00:00:00 2001 From: Kelly Sizer Date: Tue, 18 Mar 2025 23:19:04 -0500 Subject: [PATCH 2/2] Adding documentation for tags behavior --- docs/.vitepress/config.mts | 4 +++- docs/data-sources/vault-data.md | 6 +++++- docs/faq/understanding-tags.md | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 docs/faq/understanding-tags.md diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index e6b6db7..3ae5d08 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -63,7 +63,9 @@ export default defineConfig({ { text: 'FAQ', items: [ - { text: 'Comparison with Dataview', link: '/faq/comparison-with-dataview' } + { text: 'Comparison with Dataview', link: '/faq/comparison-with-dataview' }, + { text: 'Understanding Tags', link: '/faq/understanding-tags'} + ] }, { diff --git a/docs/data-sources/vault-data.md b/docs/data-sources/vault-data.md index 4e618df..2406956 100644 --- a/docs/data-sources/vault-data.md +++ b/docs/data-sources/vault-data.md @@ -23,6 +23,8 @@ Files table consists of the following columns: | `file_size` | Size of the file on disk (in bytes) | 0.18.1 | | All file properties | All file properties are also added to the table. All the special characters will be transformed to underscores `_`, so for example `note type` will be accessible as `note_type` | | +> **Note:** Tags data can exist in two contexts - as file metadata here or as an entry in the tags table. Details [here](../faq/understanding-tags.md) + ### `tags` table Tags table consists of the following columns: | Column | Description | Introduced In | @@ -31,6 +33,8 @@ Tags table consists of the following columns: | `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 | | +> **Note:** Tags data can in two contexts - as file metadata or as an entry in this tags table. Details [here](../faq/understanding-tags.md) + ### `tasks` table Tasks table consists of the following columns: | Column | Description | Introduced In | @@ -51,4 +55,4 @@ Introduced in 0.20.0 | `target` | Full path of the target of the link | | `position` | JSON object containing information about location of the link | | `display_text` | Text displayed on the page for that link | -| `target_exists` | information if the target file exists. 1 if it exists, 0 otherwise | \ No newline at end of file +| `target_exists` | information if the target file exists. 1 if it exists, 0 otherwise | diff --git a/docs/faq/understanding-tags.md b/docs/faq/understanding-tags.md new file mode 100644 index 0000000..bed69d2 --- /dev/null +++ b/docs/faq/understanding-tags.md @@ -0,0 +1,30 @@ +# Understanding Tags in SQLSeal +When working with the SQLSeal plugin in Obsidian, tags can appear in two different contexts: + +- as a frontmatter property in your files +- as rows in the `tags` table + +It is important to understand what to expect when querying them in these different contexts. + +## Tags in Frontmatter + +Obsidian’s frontmatter can include a `tags` field to declare tags directly within the YAML metadata at the top of a file. + +For example: +```yaml +--- +tags: [project, todo] +--- +``` + +These tags will appear as a list in the frontmatter and are considered a direct part of the file’s metadata. + +In the context of SQLSeal, they will be accessible when you query the files table, but they behave like any other frontmatter property-essentially as a plain list of values. + +## Tags in the tags Table + +The tags table is specifically designed to capture all tags found within the vault. Each tag in this table is represented as a separate row, along with the file path it’s associated with. For instance, if you have a tag #todo in multiple files, each instance of #todo will be recorded in the tags table, linking it to the respective file. + +## In Summary + +When using SQLSeal, keep in mind that tags from frontmatter and tags in the tags table serve different purposes and are structured differently. Frontmatter tags are essentially metadata fields of the file and appear as-is in the files table, while the tags table provides a detailed, row-based view of all tags in your vault.