lib/mongoid/persistable/upsertable.rb
# Perform an upsert of the document. If the document does not exist in the
# database, then Mongo will insert a new one, otherwise the fields will get
# overwritten with new values on the existing document.
#
# @example Upsert the document.
#   document.upsert
#
# @param [ Hash ] options The validation options.
#
# @return [ true ] True.
#
# @since 3.0.0
Perform an upsert of the document. If the document does not exist in the
database, then Mongo will insert a new one, otherwise the fields will get
overwritten with new values on the existing document.
Perform an upsert of the document . If the document does not exist in the database then Mongo will insert a new one otherwise the fields will get overwritten with new values on the existing document .
def upsert(options = {})
        prepare_upsert(options) do
          collection.find(atomic_selector).update_one(
              as_attributes, upsert: true, session: _session)
        end
      end
def upsert ( options = { } ) prepare_upsert ( options ) do collection . find ( atomic_selector ) . update_one ( as_attributes , upsert : true , session : _session ) end end
Perform an upsert of the document.
Perform an upsert of the document .
None
 true 
options
options The validation options.
options The validation options .
example
Upsert the document. document.upsert
Upsert the document . document . upsert
since
None