Sha256: 50a724cfc006dffd559f0d94d83752d495172c2c2b6e1aaffac458668188b310

Contents?: true

Size: 793 Bytes

Versions: 7

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module ROM
  module Mongo
    module Commands
      # Delete command
      #
      # Removes tuple from its target relation
      #
      # @abstract
      class Delete < ROM::Commands::Delete
        include ROM::Mongo::Commands::Helper

        adapter :mongo

        # Passes tuple to relation for deletion
        #
        # @param attributes [Hash]
        #
        # @return [Array<Hash>]
        #
        # @api public
        def execute(attributes)
          filtered_documents = dataset.find(pk.merge(attributes), projection)
          document_snapshot = process_with_schema(filtered_documents.first)
          return [document_snapshot] if filtered_documents.delete_one.deleted_count.eql?(1)

          []
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-mongodb-0.1.6 lib/rom/mongo/commands/delete.rb
rom-mongodb-0.1.5 lib/rom/mongo/commands/delete.rb
rom-mongodb-0.1.4 lib/rom/mongo/commands/delete.rb
rom-mongodb-0.1.3 lib/rom/mongo/commands/delete.rb
rom-mongodb-0.1.2 lib/rom/mongo/commands/delete.rb
rom-mongodb-0.1.1 lib/rom/mongo/commands/delete.rb
rom-mongodb-0.1.0 lib/rom/mongo/commands/delete.rb