Method: XGen::Mongo::Driver::Collection#insert
- Defined in:
- lib/mongo/collection.rb
#insert(*objects) ⇒ Object Also known as: <<
Insert objects, which are hashes. “<<” is aliased to this method. Returns either the single inserted object or a new array containing objects. The object(s) may have been modified by the database’s PK factory, if it has one.
80 81 82 83 84 |
# File 'lib/mongo/collection.rb', line 80 def insert(*objects) objects = objects.first if objects.size == 1 && objects.first.is_a?(Array) res = @db.insert_into_db(@name, objects) res.size > 1 ? res : res.first end |