@@ -46,27 +46,24 @@ func (m *mongoOperator) Replace(e model.ChangeEvent) error {
4646}
4747
4848func (m * mongoOperator ) Update (e model.ChangeEvent ) error {
49- if e .FullDocument == nil {
50- update := bson.M {}
49+ update := bson.M {}
5150
52- if len (e .UpdateDescription .UpdatedFields ) != 0 {
53- update ["$set" ] = e .UpdateDescription .UpdatedFields
54- }
51+ if len (e .UpdateDescription .UpdatedFields ) != 0 {
52+ update ["$set" ] = e .UpdateDescription .UpdatedFields
53+ }
5554
56- if len (e .UpdateDescription .RemovedFields ) != 0 {
57- unset := bson.M {}
58- for _ , field := range e .UpdateDescription .RemovedFields {
59- unset [field ] = ""
60- }
61- update ["$unset" ] = unset
55+ if len (e .UpdateDescription .RemovedFields ) != 0 {
56+ unset := bson.M {}
57+ for _ , field := range e .UpdateDescription .RemovedFields {
58+ unset [field ] = ""
6259 }
63-
64- _ , err := m .Database (e .Namespace .Database ).
65- Collection (e .Namespace .Collection ).
66- UpdateOne (context .Background (), e .DocumentKey , update )
67- return err
60+ update ["$unset" ] = unset
6861 }
69- return m .Replace (e )
62+
63+ _ , err := m .Database (e .Namespace .Database ).
64+ Collection (e .Namespace .Collection ).
65+ UpdateOne (context .Background (), e .DocumentKey , update )
66+ return err
7067}
7168
7269func (m * mongoOperator ) Drop (e model.ChangeEvent ) error {
@@ -76,8 +73,8 @@ func (m *mongoOperator) Drop(e model.ChangeEvent) error {
7673}
7774
7875func (m * mongoOperator ) Rename (e model.ChangeEvent ) error {
79- from := e .Namespace .Database + "." + e . Namespace . Collection
80- to := e .To .Database + "." + e . To . Collection
76+ from := e .Namespace .String ()
77+ to := e .To .String ()
8178
8279 result := m .Database ("admin" ).
8380 RunCommand (
0 commit comments