Module: Mongo::Operation::Write
- Includes:
- ResponseHandling
- Defined in:
- lib/mongo/operation/shared/write.rb
Overview
Shared behavior of operations that write (update, insert, delete).
Instance Method Summary collapse
-
#bulk_execute(connection, client:) ⇒ Mongo::Operation::Delete::BulkResult, ...
Execute the bulk write operation.
-
#execute(server, client:) ⇒ Mongo::Operation::Result
Execute the operation.
Instance Method Details
#bulk_execute(connection, client:) ⇒ Mongo::Operation::Delete::BulkResult, ...
Execute the bulk write operation.
70 71 72 73 74 75 76 77 78 |
# File 'lib/mongo/operation/shared/write.rb', line 70 def bulk_execute(connection, client:) Lint.assert_type(connection, Server::Connection) if connection.features.op_msg_enabled? self.class::OpMsg.new(spec).execute(connection, client: client).bulk_result else self.class::Command.new(spec).execute(connection, client: client).bulk_result end end |
#execute(server, client:) ⇒ Mongo::Operation::Result
Execute the operation.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mongo/operation/shared/write.rb', line 38 def execute(server, client:) server.with_connection do |connection| validate!(connection) op = if connection.features.op_msg_enabled? self.class::OpMsg.new(spec) elsif !acknowledged_write? self.class::Legacy.new(spec) else self.class::Command.new(spec) end result = op.execute(connection, client: client) validate_result(result, client, connection) end end |