Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Database template fields support access by ID https://github.com/siyuan-note/siyuan/issues/11237

Daniel64de28efafc4
diff --git a/kernel/sql/av.go b/kernel/sql/av.go
index 8a230899b7..4ab79d9b23 100644
--- a/kernel/sql/av.go
+++ b/kernel/sql/av.go
@@ -479,6 +479,8 @@ func RenderTemplateCol(ial map[string]string, rowValues []*av.KeyValues, tplCont
}
}
+ dataModel["id"] = map[string]any{}
+ dataModel["id_raw"] = map[string]any{}
for _, rowValue := range rowValues {
if 1 > len(rowValue.Values) {
continue
@@ -542,7 +544,12 @@ func RenderTemplateCol(ial map[string]string, rowValues []*av.KeyValues, tplCont
dataModel[rowValue.Key.Name] = v.String(true)
}
- dataModel[rowValue.Key.Name+"_raw"] = v // Database template fields support access to the raw value https://github.com/siyuan-note/siyuan/issues/14903
+ // Database template fields support access to the raw value https://github.com/siyuan-note/siyuan/issues/14903
+ dataModel[rowValue.Key.Name+"_raw"] = v
+
+ // Database template fields support access by ID https://github.com/siyuan-note/siyuan/issues/11237
+ dataModel["id"].(map[string]any)[rowValue.Key.ID] = dataModel[rowValue.Key.Name]
+ dataModel["id_raw"].(map[string]any)[rowValue.Key.ID] = v
}
if err = tpl.Execute(buf, dataModel); err != nil {