Method: MongoMapper::Document::ClassMethods#destroy

Defined in:
lib/mongo_mapper/document.rb

#destroy(id) ⇒ Object #destroy(ids) ⇒ Object

Iterates over each document found by the provided IDs and calls their destroy method. This has the advantage of processing your document’s destroy call-backs.

Examples:

Destroying a single document

Person.destroy("34")

Destroying multiple documents

Person.destroy("34", "45", ..., "54")

# OR...

Person.destroy(["34", "45", ..., "54"])

Overloads:

  • #destroy(id) ⇒ Object

    Destroy a single document by ID

    Parameters:

    • id

      the ID of the document to destroy

  • #destroy(ids) ⇒ Object

    Destroy many documents by their IDs

    Parameters:

    • the (Array)

      IDs of each document you wish to destroy



231
232
233
# File 'lib/mongo_mapper/document.rb', line 231

def destroy(*ids)
  find_some(ids.flatten).each(&:destroy)
end