Skip to content

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

:art: Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964

Danielcbddce4d25b1
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 9a03e86a20..ba0e94347d 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -44,6 +44,34 @@ import (
"github.com/xrash/smetrics"
)
+func (tx *Transaction) doRemoveAttrViewGroup(operation *Operation) (ret *TxErr) {
+ if err := removeAttributeViewGroup(operation.AvID, operation.BlockID); nil != err {
+ return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
+ }
+ return
+}
+
+func removeAttributeViewGroup(avID, blockID string) (err error) {
+ attrView, err := av.ParseAttributeView(avID)
+ if err != nil {
+ return err
+ }
+
+ view, err := getAttrViewViewByBlockID(attrView, blockID)
+ if err != nil {
+ return err
+ }
+
+ view.Group, view.Groups = nil, nil
+
+ err = av.SaveAttributeView(attrView)
+ if err != nil {
+ logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
+ return err
+ }
+ return nil
+}
+
func (tx *Transaction) doSyncAttrViewTableColWidth(operation *Operation) (ret *TxErr) {
err := syncAttrViewTableColWidth(operation)
if err != nil {
@@ -94,13 +122,13 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) {
}
func (tx *Transaction) doHideAttrViewGroup(operation *Operation) (ret *TxErr) {
- if err := HideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {
+ if err := hideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
}
return
}
-func HideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) {
+func hideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) {
attrView, err := av.ParseAttributeView(avID)
if err != nil {
return err
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 28da677cd8..89fec18261 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -303,6 +303,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
ret = tx.doHideAttrViewGroup(op)
case "syncAttrViewTableColWidth":
ret = tx.doSyncAttrViewTableColWidth(op)
+ case "removeAttrViewGroup":
+ ret = tx.doRemoveAttrViewGroup(op)
}
if nil != ret {