Method: Mongoid::Config#truncate!

Defined in:
lib/mongoid/config.rb

#truncate!true

Note:

This will be slower than purge!

Truncate all data in all collections, but not the indexes.

Examples:

Truncate all collection data.

Mongoid::Config.truncate!

Returns:

  • (true)

    true.

Since:

  • 2.0.2

[View source]

193
194
195
196
197
# File 'lib/mongoid/config.rb', line 193

def truncate!
  Sessions.default.collections.each do |collection|
    collection.find.remove_all
  end and true
end