I am trying to find a versatile query to transform blocks into tables.
Given the following block structure
#name
- child-block 1
- grandhchild-block 1
- grandchild-block 2
- child-block 2
- child-block3
- grandchild-block4
- great-grandchild1
- greant-grandchild2
- grandhchild-block5
Can I construct a query that generates a table with the following schema?
table title:#name
child-block1 |
child-block2 |
childblock3 |
grandchild-block1 |
grandchild-block3 |
grandchildblock4 - great-grandchild1 - great-grandchild2 |
granchild-block2 |
“” |
grandchild-block5 |
Essentially
- the child blocks would be treated as table headers.
- the grand-child blocks would be treated as values
- any child below the grand-chilld would be listed as bullet points within the grandchild’s cell
Additionally, if there is a way to append any new properly structured #name block to the table created by the query (instead of having multiple #name tables), that would make for a perfect versatile query to coalesce structured content.
Thank you!
Thank you for your feedback @mentaloid
Complexity
I am aware of it and wondered if I should ask for a the simplest version of my request first. A starting point could be to simply be able to transform
title
- child block1
- child block2
into
child block2 |
child block2 |
grandchild block1 |
grandchild block2 |
Usefulness
This query would essentiallty be the complement to templates.
Imagine that you have a template to document your work achievements
#workachievement
- company
- role
- task
- achievement
Company |
Role |
Task |
Achievement |
value1 |
value2 |
value3 |
value4 |
or your mood journal
#mood
- today I…
- this made me feel…
- the reason is…
Today I… |
This made me feel… |
The reason is… |
value1 |
value2 |
value3 |
or your project ideas
#projectidea
- description
- target problem
- expected benefit
- proposed implementation
Description |
Target Problem |
Expected Benefit |
Proposed Implementation |
value1 |
value2 |
value3 |
value4 |
You could copy paste the query in the #workachievement or #mood or #projectidea pages, and, just by changing the target hashtag, get a summary table that would give you an overview of your notes on the topic. Thinking about it, adding the date of the note could make it even more useful.
Properties
I have seen an example about using properties for a table of film reviews, and I am open to a suggestion that would make use of properties.
The reason why I asked for a query that builds on the basic nested writing structure of Logseq is that
- there is a clear, almost natural, relationship between a (shallow) nested block and a table. So converting similarly structured blocks in a table sounds to me like a natural extension of grouping blocks that have the same tag
- Creating properties for each child of each template would lead the a lot of tags that have very little organisational value beyond the creation of the table. Properties are often topic dependent, and a #description pulling blocks from any topic would have little value.