Method: Mongo::Collection#remove
- Defined in:
- lib/mongo/collection.rb
#remove(selector = {}, opts = {}) ⇒ Hash, true
Remove all documents from this collection.
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/mongo/collection.rb', line 408 def remove(selector={}, opts={}) write_concern = get_write_concern(opts, self) = BSON::ByteBuffer.new("\0\0\0\0", @connection.) BSON::BSON_RUBY.serialize_cstr(, "#{@db.name}.#{@name}") .put_int(0) .put_binary(BSON::BSON_CODER.serialize(selector, false, true, @connection.max_bson_size).to_s) instrument(:remove, :database => @db.name, :collection => @name, :selector => selector) do if Mongo::WriteConcern.gle?(write_concern) @connection.(Mongo::Constants::OP_DELETE, , @db.name, nil, write_concern) else @connection.(Mongo::Constants::OP_DELETE, ) true end end end |