File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -184,10 +184,20 @@ private void _PerformUpdates() {
184
184
185
185
//if this hasn't changed then skip it
186
186
if ( item . Key . Equals ( item . Value . GetObjectHash ( ) ) ) { continue ; }
187
- Console . WriteLine ( "Updating " + item . Value . Get < string > ( "name" ) ) ;
188
187
189
- this . Find ( ) . FindById ( item . Value . Id ) . Set ( item . Value ) ;
190
- this . Find ( ) . FindById ( item . Value . Id ) . Unset ( item . Value . GetRemovedFields ( ) . ToArray ( ) ) ;
188
+ //create a bson document of the update to create
189
+ BsonDocument update = new BsonDocument ( ) ;
190
+ update . Merge ( item . Value ) ;
191
+ update . Remove ( Mongo . DocumentIdKey ) ;
192
+
193
+ //start with the update
194
+ this . Find ( ) . FindById ( item . Value . Id ) . Set ( update ) ;
195
+
196
+ //check for anything removed
197
+ IEnumerable < string > removed = item . Value . GetRemovedFields ( ) ;
198
+ if ( removed . Count ( ) > 0 ) {
199
+ this . Find ( ) . FindById ( item . Value . Id ) . Unset ( removed . ToArray ( ) ) ;
200
+ }
191
201
192
202
//Might want to try and merge this into the same
193
203
//request to avoid two trips to the database -- But
You can’t perform that action at this time.
0 commit comments