mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 00:50:56 +08:00
🎨 Supports searching database view content https://github.com/siyuan-note/siyuan/issues/9419
This commit is contained in:
parent
a11ea9c347
commit
c3d1c04af4
@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -190,6 +191,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||||||
ret = tx.doUnfoldHeading(op)
|
ret = tx.doUnfoldHeading(op)
|
||||||
case "setAttrs":
|
case "setAttrs":
|
||||||
ret = tx.doSetAttrs(op)
|
ret = tx.doSetAttrs(op)
|
||||||
|
case "doUpdateUpdated":
|
||||||
|
ret = tx.doUpdateUpdated(op)
|
||||||
case "addFlashcards":
|
case "addFlashcards":
|
||||||
ret = tx.doAddFlashcards(op)
|
ret = tx.doAddFlashcards(op)
|
||||||
case "removeFlashcards":
|
case "removeFlashcards":
|
||||||
@ -987,6 +990,35 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *Transaction) doUpdateUpdated(operation *Operation) (ret *TxErr) {
|
||||||
|
id := operation.ID
|
||||||
|
tree, err := tx.loadTree(id)
|
||||||
|
if nil != err {
|
||||||
|
if errors.Is(err, ErrBlockNotFound) {
|
||||||
|
logging.LogWarnf("not found block [%s]", id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.LogErrorf("load tree [%s] failed: %s", id, err)
|
||||||
|
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
||||||
|
}
|
||||||
|
|
||||||
|
node := treenode.GetNodeInTree(tree, id)
|
||||||
|
if nil == node {
|
||||||
|
logging.LogErrorf("get node [%s] in tree [%s] failed", id, tree.Root.ID)
|
||||||
|
return &TxErr{msg: ErrBlockNotFound.Error(), id: id}
|
||||||
|
}
|
||||||
|
|
||||||
|
updated := int64(operation.Data.(float64))
|
||||||
|
node.SetIALAttr("updated", strconv.FormatInt(updated, 10))
|
||||||
|
createdUpdated(node)
|
||||||
|
tx.nodes[node.ID] = node
|
||||||
|
if err = tx.writeTree(tree); nil != err {
|
||||||
|
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: id}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doCreate(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doCreate(operation *Operation) (ret *TxErr) {
|
||||||
tree := operation.Data.(*parse.Tree)
|
tree := operation.Data.(*parse.Tree)
|
||||||
tx.writeTree(tree)
|
tx.writeTree(tree)
|
||||||
|
Loading…
Reference in New Issue
Block a user