File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -172,11 +172,26 @@ def initialize(options = {}, &block)
172172 def supports? ( feature )
173173 case feature . to_sym
174174 when :graph_name then true
175+ when :atomic_write then true
175176 when :validity then @options . fetch ( :with_validity , true )
176177 else false
177178 end
178179 end
179180
181+ def apply_changeset ( changeset )
182+ ops = [ ]
183+
184+ changeset . deletes . each do |d |
185+ ops << { delete_one : { filter : statement_to_delete ( d ) } }
186+ end
187+
188+ changeset . inserts . each do |i |
189+ ops << { update_one : { filter : statement_to_insert ( i ) , update : statement_to_insert ( i ) , upsert : true } }
190+ end
191+
192+ @collection . bulk_write ( ops , ordered : true )
193+ end
194+
180195 def insert_statement ( statement )
181196 st_mongo = statement_to_insert ( statement )
182197 @collection . update_one ( st_mongo , st_mongo , upsert : true )
You can’t perform that action at this time.
0 commit comments