An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add Relation and Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9888
Danielc916cd0c2315
diff --git a/kernel/api/av.go b/kernel/api/av.goindex 8207c97243..c53b247efb 100644--- a/kernel/api/av.go+++ b/kernel/api/av.go@@ -26,6 +26,22 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func getAttributeView(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, _ := util.JsonArg(c, ret)+ if nil == arg {+ return+ }++ id := arg["id"].(string)+ av := model.GetAttributeView(id)+ ret.Data = map[string]interface{}{+ "av": av,+ }+}+func searchAttributeView(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/api/router.go b/kernel/api/router.goindex 910dcf2bb7..e3b5ff7df5 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -387,6 +387,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/av/getAttributeViewKeys", model.CheckAuth, getAttributeViewKeys)ginServer.Handle("POST", "/api/av/setAttributeViewBlockAttr", model.CheckAuth, model.CheckReadonly, setAttributeViewBlockAttr)ginServer.Handle("POST", "/api/av/searchAttributeView", model.CheckAuth, model.CheckReadonly, searchAttributeView)+ ginServer.Handle("POST", "/api/av/getAttributeView", model.CheckAuth, model.CheckReadonly, getAttributeView)ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, chatGPT)ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, chatGPTWithAction)diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex d077513f49..d9f05c255b 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -37,6 +37,13 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func GetAttributeView(avID string) (ret *av.AttributeView) {+ waitForSyncingStorages()++ ret, _ = av.ParseAttributeView(avID)+ return+}+type SearchAttributeViewResult struct {AvID string `json:"avID"`AvName string `json:"avName"`@@ -721,18 +728,18 @@ func (tx *Transaction) doUpdateAttrViewColRelation(operation *Operation) (ret *T}func updateAttributeViewColRelation(operation *Operation) (err error) {- err = updateAttributeViewColRelation0(operation.AvID, operation.KeyID, operation.ID, operation.IsBiRelation, operation.BackRelationKeyID)+ err = updateAttributeViewColRelation0(operation.AvID, operation.KeyID, operation.ID, operation.IsBiRelation, operation.BackRelationKeyID, operation.Name)if nil != err {return}if operation.IsBiRelation {- err = updateAttributeViewColRelation0(operation.ID, operation.BackRelationKeyID, operation.AvID, operation.IsBiRelation, operation.KeyID)+ err = updateAttributeViewColRelation0(operation.ID, operation.BackRelationKeyID, operation.AvID, operation.IsBiRelation, operation.KeyID, operation.Name)}return}-func updateAttributeViewColRelation0(avID, relKeyID, destAvID string, isBiRel bool, backRelKeyID string) (err error) {+func updateAttributeViewColRelation0(avID, relKeyID, destAvID string, isBiRel bool, backRelKeyID, backRelKeyName string) (err error) {attrView, err := av.ParseAttributeView(avID)if nil != err {return