Diff records with new diff package
This commit is contained in:
parent
e97cac18e8
commit
5fffc4bb73
1 changed files with 9 additions and 3 deletions
|
@ -16,14 +16,20 @@ package item
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
"github.com/abcum/surreal/util/json"
|
"github.com/abcum/surreal/util/diff"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *Doc) diff() *data.Doc {
|
func (this *Doc) diff() *data.Doc {
|
||||||
|
|
||||||
va := this.initial.Data().(map[string]interface{})
|
va := this.initial.Data().(map[string]interface{})
|
||||||
vb := this.current.Data().(map[string]interface{})
|
vb := this.current.Data().(map[string]interface{})
|
||||||
patch, _ := json.Diff(va, vb)
|
|
||||||
return data.Consume(patch)
|
dif := diff.Diff(va, vb).Out()
|
||||||
|
|
||||||
|
if len(dif) == 0 {
|
||||||
|
return data.Consume(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.Consume(dif)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue