Sha256: cf9c67b8f51e066f560b38f59e7e4b99478c01542eee4d58b1a378815b1f53fb

Contents?: true

Size: 218 Bytes

Versions: 1

Compression:

Stored size: 218 Bytes

Contents

#
# upsert
# 
Mongo::Collection.class_eval do
  def upsert! query, opt
    opt.size.must == 1
    opt.must_be.a Hash
    opt.values.first.must_be.a Hash
    
    update(query, opt, {upsert: true, safe: true})
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_mapper_ext-0.2.3 lib/mongo_db_ext/micelaneous.rb