Diff records with new diff package

This commit is contained in:
Tobie Morgan Hitchcock 2017-02-28 10:46:06 +00:00
parent e97cac18e8
commit 5fffc4bb73

View file

@ -16,14 +16,20 @@ package item
import (
"github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/json"
"github.com/abcum/surreal/util/diff"
)
func (this *Doc) diff() *data.Doc {
va := this.initial.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)
}