lib/mongo/collection.rb
# Drop the collection. Will also drop all indexes associated with the
# collection.
#
# @note An error returned if the collection doesn't exist is suppressed.
#
# @example Drop the collection.
#   collection.drop
#
# @param [ Hash ] opts The options for the drop operation.
#
# @option options [ Session ] :session The session to use for the operation.
# @option opts [ Hash ] :write_concern The write concern options.
#
# @return [ Result ] The result of the command.
#
# @since 2.0.0
Drop the collection. Will also drop all indexes associated with the
collection.
Drop the collection . Will also drop all indexes associated with the collection .
def drop(opts = {})
      client.send(:with_session, opts) do |session|
        temp_write_concern = write_concern
        write_concern = if opts[:write_concern]
          WriteConcern.get(opts[:write_concern])
        else
          temp_write_concern
        end
        Operation::Drop.new({
                              selector: { :drop => name },
                              db_name: database.name,
                              write_concern: write_concern,
                              session: session,
                              }).execute(next_primary(nil, session), context: Operation::Context.new(client: client, session: session))
      end
    rescue Error::OperationFailure => ex
      if ex.code == 26 || ex.code.nil? && ex.message =~ /ns not found/
        false
      else
        raise
      end
    end
def drop ( opts = { } ) client . send ( :with_session , opts ) do | session | temp_write_concern = write_concern write_concern = if opts [ :write_concern ] WriteConcern . get ( opts [ :write_concern ] ) else temp_write_concern end Operation :: Drop . new ( { selector : { :drop => name } , db_name : database . name , write_concern : write_concern , session : session , } ) . execute ( next_primary ( nil , session ) , context : Operation :: Context . new ( client : client , session : session ) ) end rescue Error :: OperationFailure => ex if ex . code == 26 || ex . code . nil? && ex . message =~ / ns not found / false else raise end end
Drop the collection.
Drop the collection .
# NamespaceNotFound
The result of the command.
The result of the command .
 Result 
opts
:write_concern The write concern options.
: write_concern The write concern options .
<not_specific>
opts The options for the drop operation.
opts The options for the drop operation .
options
<not_specific>
:session The session to use for the operation.
: session The session to use for the operation .
note
An error returned if the collection doesn't exist is suppressed.
An error returned if the collection doesn ' t exist is suppressed .
example
Drop the collection. collection.drop
Drop the collection . collection . drop
since
None