Zuoqiu-Yingyi / widget-query

一个将思源笔记数据库查询结果以表格样式渲染的挂件 | A widget that renders the query results of the Siyuan Notes database in tabular style.
GNU Affero General Public License v3.0
53 stars 7 forks source link

怎么显示自定义属性啊 #29

Closed lmmxj closed 2 years ago

lmmxj commented 2 years ago

把自定义属性名作为一列这样的,比如id,content,custom-aa,custom-bb

Zuoqiu-Yingyi commented 2 years ago

把自定义属性名作为一列这样的,比如id,content,custom-aa,custom-bb

可能需要在查询前确定想要显示的块属性,如果可以接受的话我写一个示例

lmmxj commented 2 years ago

麻烦写个示例吧,另外自定义属性可能不是每条数据都有,能显示所有数据吗

Zuoqiu-Yingyi commented 2 years ago

麻烦写个示例吧,另外自定义属性可能不是每条数据都有,能显示所有数据吗

SELECT
    '[' || b.content || '](siyuan://blocks/' || a.block_id || ')' AS __1____pre__文档标题,
    MAX(
        CASE
            WHEN a.name = 'name' THEN a.value
            ELSE NULL
        END
    ) AS __2____kbd__命名,
    MAX(
        CASE
            WHEN a.name = 'alias' THEN REPLACE(
                '<kbd>' || a.value || '</kbd>',
                ',',
                '</kbd><br/><kbd>'
            )
            ELSE NULL
        END
    ) AS __3____pre__别名,
    MAX(
        CASE
            WHEN a.name = 'memo' THEN REPLACE(
                '<kbd>' || a.value || '</kbd>',
                ',',
                '</kbd><br/><kbd>'
            )
            ELSE NULL
        END
    ) AS __3____pre__备注
FROM
    attributes AS a
    INNER JOIN blocks AS b ON a.block_id = b.id
WHERE
    (
        a.name = 'name'
        OR a.name = 'alias'
        OR a.name = 'memo'
    )
    AND b.type = 'd'
GROUP BY
    a.block_id
ORDER BY
    RANDOM()
LIMIT
    10;

image 下个版本我试试能不能自动处理

Zuoqiu-Yingyi commented 2 years ago

@lmmxj [思源笔记经验分享] 使用 Query 挂件实现属性视图 - 链滴

lmmxj commented 2 years ago

IAL 渲染为多列:不能用query-fields的方式选择ial里的字段,只要不为空都会列出

自定义查询: 没有任何自定义属性的文件,会显示不出来。 attributes as a INNER JOIN blocks as b on a.block_id = b.id ​ 不能 right join

 

------------------ 原始邮件 ------------------ 发件人: "Zuoqiu-Yingyi/widget-query" @.>; 发送时间: 2022年4月10日(星期天) 凌晨1:55 @.>; @.**@.>; 主题: Re: [Zuoqiu-Yingyi/widget-query] 怎么显示自定义属性啊 (Issue #29)

@lmmxj [思源笔记经验分享] 使用 Query 挂件实现属性视图 - 链滴

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Zuoqiu-Yingyi commented 2 years ago

IAL 渲染为多列:不能用query-fields的方式选择ial里的字段,只要不为空都会列出

自定义查询: 没有任何自定义属性的文件,会显示不出来。 attributes as a INNER JOIN blocks as b on a.block_id = b.id ​ 不能 right join

了解,那我再用一个新字段控制 ial 渲染吧🙂

lmmxj commented 2 years ago

个人感觉最好是 能弄个类似临时表的方式,把自定义属性追加到 blocks里,这样能改显示的字段名。最好是可以直接在查询的页面修改自定义属性那种。 九炎之前做的属性面板有这个功能,但是那个版本被他修改后,也找不到自定义属性了,旧版又被我删了。 当然,能实现查询功能就可以满足大部分需要了。

------------------ 原始邮件 ------------------ 发件人: "Zuoqiu-Yingyi/widget-query" @.>; 发送时间: 2022年4月10日(星期天) 上午10:26 @.>; @.**@.>; 主题: Re: [Zuoqiu-Yingyi/widget-query] 怎么显示自定义属性啊 (Issue #29)

IAL 渲染为多列:不能用query-fields的方式选择ial里的字段,只要不为空都会列出

自定义查询: 没有任何自定义属性的文件,会显示不出来。 attributes as a INNER JOIN blocks as b on a.block_id = b.id ​ 不能 right join

了解,那我再用一个新字段控制 ial 渲染吧🙂

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Zuoqiu-Yingyi commented 2 years ago

个人感觉最好是 能弄个类似临时表的方式,把自定义属性追加到 blocks里,这样能改显示的字段名。最好是可以直接在查询的页面修改自定义属性那种。 九炎之前做的属性面板有这个功能,但是那个版本被他修改后,也找不到自定义属性了,旧版又被我删了。 当然,能实现查询功能就可以满足大部分需要了。

思源提供的数据库 API 只能查询, 不支持增删改~ 不过刚刚我在配置中设置了三个配置选项

配合块自定义属性可以覆盖, 例如设置如下自定义块属性会强制渲染 namealias query-render-ial-fields-forced: ['name', 'alias']

Zuoqiu-Yingyi commented 2 years ago

@all-contributors please add @lmmxj for ideas

allcontributors[bot] commented 2 years ago

@Zuoqiu-Yingyi

I've put up a pull request to add @lmmxj! :tada: