Module: Mongoid::Commands::ClassMethods

Defined in:
lib/mongoid/commands.rb

Instance Method Summary collapse

Instance Method Details

#create(attributes = {}) ⇒ Object

Create a new Document with the supplied attributes. Will delegate to the Create command.



77
78
79
# File 'lib/mongoid/commands.rb', line 77

def create(attributes = {})
  Create.execute(new(attributes))
end

#create!(attributes = {}) ⇒ Object

Create a new Document with the supplied attributes. Will delegate to the Create command or raise ValidationError if the save failed validation.

Raises:



84
85
86
87
88
# File 'lib/mongoid/commands.rb', line 84

def create!(attributes = {})
  document = Create.execute(new(attributes))
  raise ValidationsError unless document.errors.empty?
  return document
end

#delete_all(conditions = {}) ⇒ Object

Delete all the Documents in the database given the supplied conditions.



92
93
94
# File 'lib/mongoid/commands.rb', line 92

def delete_all(conditions = {})
  DeleteAll.execute(self, conditions)
end

#destroy_all(conditions = {}) ⇒ Object

Destroy all the Documents in the database given the supplied conditions.



98
99
100
# File 'lib/mongoid/commands.rb', line 98

def destroy_all(conditions = {})
  DestroyAll.execute(self, conditions)
end