Skip to content

Commit

Permalink
🎨 Supports multiple views for the database #9751
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 1, 2023
1 parent ee9844c commit f9edbe0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,30 @@ func (tx *Transaction) doAddAttrViewView(operation *Operation) (ret *TxErr) {
return
}

func (tx *Transaction) doSetAttrViewViewName(operation *Operation) (ret *TxErr) {
var err error
avID := operation.AvID
attrView, err := av.ParseAttributeView(avID)
if nil != err {
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
return &TxErr{code: TxErrWriteAttributeView, id: avID}
}

viewID := operation.ID
view := attrView.GetView(viewID)
if nil == view {
logging.LogErrorf("get view [%s] failed: %s", viewID, err)
return &TxErr{code: TxErrWriteAttributeView, id: viewID}
}

view.Name = operation.Data.(string)
if err = av.SaveAttributeView(attrView); nil != err {
logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)
return &TxErr{code: TxErrWriteAttributeView, msg: err.Error(), id: avID}
}
return
}

func (tx *Transaction) doSetAttrViewName(operation *Operation) (ret *TxErr) {
err := setAttributeViewName(operation)
if nil != err {
Expand Down
2 changes: 2 additions & 0 deletions kernel/model/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
ret = tx.doAddAttrViewView(op)
case "removeAttrViewView":
ret = tx.doRemoveAttrViewView(op)
case "setAttrViewViewName":
ret = tx.doSetAttrViewViewName(op)
}

if nil != ret {
Expand Down

0 comments on commit f9edbe0

Please sign in to comment.