I have this on a template and it’s to track expenses from my journal.
Now I have an expenses page, and I can use
{{query (property :clase "gasto")}}
And as a child a block to show the total sum
**Total Importe:** {{function (sum :importe)}}
And it works like a charm, but I want to learn clojure/datalog, and want to do it with advanced queries and customize the result.
I ended with this advanced query
{:title [:h3 "Gastos del mes"]
:query [:find (pull ?b [*])
:where
(property ?b :clase "gasto")]
:view (fn [rows] [:table
[:thead
[:tr
[:th "Concepto"]
[:th "Importe"]
]
]
[:tbody
(for [r rows]
[:tr
[:td (get r [:block/content])] ; this is my issue, just tried this after several tests to see if this works
[:td (get-in r [:block/properties :importe])]
]
)
]])
}
And it works, but I can’t get in the first column (Concepto) to show the “content” of the block (on my previous example, the text [[Youtube Premium]]
Doubts:
How can I get the content/text of the block?
Is this advanced query code old? I got it from a published graph on internet, and I didn’t saw the use of tables and get-in here in the forum.
It’s possible to get at the end of the table, an empty record showing at “Importe” column the sum of all values?
Can drop the entire view in favor of the use of the table option.
However the way to show total remains the same if you also want the details.
It is possible to give a total only though.
Here’s a modified “true” advanced query for what you’re trying to do.
Never mind the exact id’s they are specific to my graph.
You can see that :block/content contains everything. If we’re only interested in the first line, we’ll need to do some manipulation.
Can click on the content in column Concepto to go to the actual block.
Only as far as my last query I posted goes. There are some other ways. It depends on what you wish for. I just don’t know of a way to do so in a details table.