mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
🎨 Synchronize the related entries when the database creates a two-way relation https://github.com/siyuan-note/siyuan/issues/11250
This commit is contained in:
parent
bf4b9cf146
commit
eb320f9b84
1 changed files with 4 additions and 6 deletions
|
|
@ -1611,10 +1611,9 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
|
|||
srcKeyValues := keyValues
|
||||
for _, srcVal := range srcKeyValues.Values {
|
||||
for _, blockID := range srcVal.Relation.BlockIDs {
|
||||
destVal := &av.Value{ID: ast.NewNodeID(), KeyID: destKeyValues.Key.ID, BlockID: blockID, Type: keyValues.Key.Type, Relation: &av.ValueRelation{}}
|
||||
destVal := &av.Value{ID: ast.NewNodeID(), KeyID: destKeyValues.Key.ID, BlockID: blockID, Type: keyValues.Key.Type, Relation: &av.ValueRelation{}, CreatedAt: now, UpdatedAt: now + 1000}
|
||||
destVal.Relation.BlockIDs = append(destVal.Relation.BlockIDs, srcVal.BlockID)
|
||||
destVal.Relation.BlockIDs = gulu.Str.RemoveDuplicatedElem(destVal.Relation.BlockIDs)
|
||||
destVal.SetUpdatedAt(now)
|
||||
destKeyValues.Values = append(destKeyValues.Values, destVal)
|
||||
}
|
||||
}
|
||||
|
|
@ -3237,13 +3236,12 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
|
|||
|
||||
destVal := keyValues.GetValue(blockID)
|
||||
if nil == destVal {
|
||||
destVal = &av.Value{ID: ast.NewNodeID(), KeyID: keyValues.Key.ID, BlockID: blockID, Type: keyValues.Key.Type, Relation: &av.ValueRelation{}}
|
||||
destVal = &av.Value{ID: ast.NewNodeID(), KeyID: keyValues.Key.ID, BlockID: blockID, Type: keyValues.Key.Type, Relation: &av.ValueRelation{}, CreatedAt: now, UpdatedAt: now + 1000}
|
||||
keyValues.Values = append(keyValues.Values, destVal)
|
||||
}
|
||||
|
||||
destVal.Relation.BlockIDs = append(destVal.Relation.BlockIDs, rowID)
|
||||
destVal.Relation.BlockIDs = gulu.Str.RemoveDuplicatedElem(destVal.Relation.BlockIDs)
|
||||
destVal.SetUpdatedAt(now)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue