mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-01 10:20:16 +01:00
🎨 Add Relation and Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9888
This commit is contained in:
parent
a41eac8659
commit
87096f9671
3 changed files with 50 additions and 9 deletions
|
|
@ -655,6 +655,44 @@ func getRowBlockValue(keyValues []*av.KeyValues) (ret *av.Value) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doUpdateAttrViewColRelation(operation *Operation) (ret *TxErr) {
|
||||
err := updateAttributeViewColRelation(operation)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func updateAttributeViewColRelation(operation *Operation) (err error) {
|
||||
err = updateAttributeViewColRelation0(operation.AvID, operation.KeyID, operation.ID, operation.IsBiRelation, operation.BackRelationKeyID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
if operation.IsBiRelation {
|
||||
err = updateAttributeViewColRelation0(operation.ID, operation.BackRelationKeyID, operation.AvID, operation.IsBiRelation, operation.KeyID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func updateAttributeViewColRelation0(avID, relKeyID, destAvID string, isBiRel bool, backRelKeyID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
if keyValues.Key.ID == relKeyID {
|
||||
keyValues.Key.RelationAvID = destAvID
|
||||
keyValues.Key.IsBiRelation = isBiRel
|
||||
keyValues.Key.BackRelationKeyID = backRelKeyID
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSortAttrViewView(operation *Operation) (ret *TxErr) {
|
||||
avID := operation.AvID
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue