-
在数据表中,求一个模板,根据添加到数据库的主键的那个文档,返回它的父文档链接
2024-12-11 01:07这边放下去掉空余空格后的代码,运行良好很完美。供需要的朋友直接取用。顺便说下这个应用场景:
以父文档及标题作为项目,然后以子文档标题作为项目下的各种子任务。把子任务文档发送到一个任务管理的数据库表中,任务执行的上下文数据存储在子任务文档中。随着任务的杂多,适当的在数据库表中自动展示父文档即“任务所属项目”有一定的必要性。
.action{ if index . "custom-avs" }.action{$id := .id}.action{$blocks := queryBlocks "select * from blocks where id='?'" $id}.action{ $b := first $blocks}.action{$list := splitList $b.ID $b.Path }.action{$f := first $list }.action{$len := len $f }.action{$len := sub $len 1 }.action{$len := int $len }.action{ if ne 0 $len }.action{$f := substr 1 $len $f}.action{$list := splitList "/" $f }.action{$ParentID := last $list }.action{$ParentID := trim $ParentID }.action{$blocks := queryBlocks "select * from blocks where id='?'" $ParentID}.action{$b := first $blocks}<span data-type="block-ref" data-id=".action{$b.ID}" data-subtype="s" class="av__celltext av__celltext--ref" style="">.action{$b.Content}</span>.action{ end }.action{ end }
-
在数据表中,求一个模板,根据添加到数据库的主键的那个文档,返回它的父文档链接
2024-12-10 23:54佬,捉个小瑕疵,这个模板在如下条件组合下,会跳出黑框:
条件一:设置链接只有在“ctrl + 鼠标”触碰下才预览。
条件二:模板的那个列没有开启换行(开启换行会有个问题,就是会有非常大的空白段在表格列中。),在没有开启换行的情况下,文档的标题链接超出了单元格的宽度。
在上面两个条件下,把鼠标触碰模板列中的链接,会跳出如下黑框。但是,Ctrl + 鼠标触碰则是正常的预览。
当把单元格拉长能够完全显示模板列中的标题时,鼠标再进行触碰则是符合预期的什么也没有。(因为设置的就是需要 ctrl)。
-
分享一个极简任务追踪和回顾的 Query
2024-11-25 11:00-- 查询72h更新的文档 SELECT '[' || b.hpath || '](siyuan://blocks/' || b.id || ')' AS __1____pre__文档路径, CASE WHEN b.updated != '' THEN b.updated ELSE b.created END AS __2____datetime__最后更新时间, b.created AS __3____datetime__创建时间, printf('%d天%d小时%d分钟%d秒', ABS( (CAST(SUBSTR(b.updated, 1, 4) AS INTEGER) - CAST(SUBSTR(b.created, 1, 4) AS INTEGER)) * 365 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 5, 2) AS INTEGER) - CAST(SUBSTR(b.created, 5, 2) AS INTEGER)) * 30 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 7, 2) AS INTEGER) - CAST(SUBSTR(b.created, 7, 2) AS INTEGER)) * 24 * 60 * 60 + (CAST(SUBSTR(b.updated,9, 2) AS INTEGER) - CAST(SUBSTR(b.created, 9, 2) AS INTEGER)) * 60 * 60 + (CAST(SUBSTR(b.updated, 11, 2) AS INTEGER) - CAST(SUBSTR(b.created, 11, 2) AS INTEGER)) * 60 + (CAST(SUBSTR(b.updated, 13, 2) AS INTEGER) - CAST(SUBSTR(b.created, 13, 2) AS INTEGER)) ) / 86400, -- 天 ABS( (CAST(SUBSTR(b.updated, 1, 4) AS INTEGER) - CAST(SUBSTR(b.created, 1, 4) AS INTEGER)) * 365 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 5, 2) AS INTEGER) - CAST(SUBSTR(b.created, 5, 2) AS INTEGER)) * 30 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 7, 2) AS INTEGER) - CAST(SUBSTR(b.created, 7, 2) AS INTEGER)) * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 9, 2) AS INTEGER) - CAST(SUBSTR(b.created, 9, 2) AS INTEGER)) * 60 * 60 + (CAST(SUBSTR(b.updated, 11, 2) AS INTEGER) - CAST(SUBSTR(b.created, 11, 2) AS INTEGER)) * 60 + (CAST(SUBSTR(b.updated, 13, 2) AS INTEGER) - CAST(SUBSTR(b.created, 13, 2) AS INTEGER)) ) % 86400 / 3600, -- 小时 ABS( (CAST(SUBSTR(b.updated, 1, 4) AS INTEGER) - CAST(SUBSTR(b.created, 1, 4) AS INTEGER)) * 365 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 5, 2) AS INTEGER) - CAST(SUBSTR(b.created, 5, 2) AS INTEGER)) * 30 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 7, 2) AS INTEGER) - CAST(SUBSTR(b.created, 7, 2) AS INTEGER)) * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 9, 2) AS INTEGER) - CAST(SUBSTR(b.created, 9, 2) AS INTEGER)) * 60 * 60 + (CAST(SUBSTR(b.updated, 11, 2) AS INTEGER) - CAST(SUBSTR(b.created, 11, 2) AS INTEGER)) * 60 + (CAST(SUBSTR(b.updated, 13, 2) AS INTEGER) - CAST(SUBSTR(b.created, 13, 2) AS INTEGER)) ) % 3600 / 60, -- 分钟 ABS( (CAST(SUBSTR(b.updated, 1, 4) AS INTEGER) - CAST(SUBSTR(b.created, 1, 4) AS INTEGER)) * 365 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 5, 2) AS INTEGER) - CAST(SUBSTR(b.created, 5, 2) AS INTEGER)) * 30 * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 7, 2) AS INTEGER) - CAST(SUBSTR(b.created, 7, 2) AS INTEGER)) * 24 * 60 * 60 + (CAST(SUBSTR(b.updated, 9, 2) AS INTEGER) - CAST(SUBSTR(b.created, 9, 2) AS INTEGER)) * 60 * 60 + (CAST(SUBSTR(b.updated, 11, 2) AS INTEGER) - CAST(SUBSTR(b.created, 11, 2) AS INTEGER)) * 60 + (CAST(SUBSTR(b.updated, 13, 2) AS INTEGER) - CAST(SUBSTR(b.created, 13, 2) AS INTEGER)) ) % 60 -- 秒 ) AS __4____pre__间隔时间 FROM blocks AS b WHERE b.type = 'd' AND b.root_id != '.block{.root_id}' AND ( b.updated > strftime( '%Y%m%d%H%M%S', 'now', 'localtime', '-3 day' ) OR b.created > strftime( '%Y%m%d%H%M%S', 'now', 'localtime', '-3 day' ) ) ORDER BY __2____datetime__最后更新时间 DESC LIMIT -1;
-
批量导入文档到数据库 0.0.6 版全新发布
2024-11-10 15:09如果我想把笔记本 id 作为父文档 id,这个可行吗。如果现在的代码不可行,该怎么改动啊。还有请教一下楼主。这个代码在 vscode 中打开怎么那么乱啊。在 vscode 里面该怎么排班呢。