(self, spec, document, upsert=False, manipulate=False,
               multi=False, check_keys=True, **kwargs)
Update a document(s) in this collection.

        **DEPRECATED** - Use :meth:`replace_one`, :meth:`update_one`, or
        :meth:`update_many` instead.

        .. versionchanged:: 3.0
           Removed the `safe` parameter. Pass ``w=0`` for unacknowledged write
           operations.
Update a document(s) in this collection.
Update a document ( s ) in this collection .
def update(self, spec, document, upsert=False, manipulate=False,
               multi=False, check_keys=True, **kwargs):
        """Update a document(s) in this collection.

        **DEPRECATED** - Use :meth:`replace_one`, :meth:`update_one`, or
        :meth:`update_many` instead.

        .. versionchanged:: 3.0
           Removed the `safe` parameter. Pass ``w=0`` for unacknowledged write
           operations.
        """
        warnings.warn("update is deprecated. Use replace_one, update_one or "
                      "update_many instead.", DeprecationWarning, stacklevel=2)
        common.validate_is_mapping("spec", spec)
        common.validate_is_mapping("document", document)
        if document:
            # If a top level key begins with '$' this is a modify operation
            # and we should skip key validation. It doesn't matter which key
            # we check here. Passing a document with a mix of top level keys
            # starting with and without a '$' is invalid and the server will
            # raise an appropriate exception.
            first = next(iter(document))
            if first.startswith('$'):
                check_keys = False

        write_concern = None
        collation = validate_collation_or_none(kwargs.pop('collation', None))
        if kwargs:
            write_concern = WriteConcern(**kwargs)
        with self._socket_for_writes() as sock_info:
            return self._update(sock_info, spec, document, upsert,
                                check_keys, multi, manipulate, write_concern,
                                collation=collation)
def update ( self , spec , document , upsert = False , manipulate = False , multi = False , check_keys = True , * * kwargs ) : warnings . warn ( "update is deprecated. Use replace_one, update_one or " "update_many instead." , DeprecationWarning , stacklevel = 2 ) common . validate_is_mapping ( "spec" , spec ) common . validate_is_mapping ( "document" , document ) if document : # If a top level key begins with '$' this is a modify operation # and we should skip key validation. It doesn't matter which key # we check here. Passing a document with a mix of top level keys # starting with and without a '$' is invalid and the server will # raise an appropriate exception. first = next ( iter ( document ) ) if first . startswith ( '$' ) : check_keys = False write_concern = None collation = validate_collation_or_none ( kwargs . pop ( 'collation' , None ) ) if kwargs : write_concern = WriteConcern ( * * kwargs ) with self . _socket_for_writes ( ) as sock_info : return self . _update ( sock_info , spec , document , upsert , check_keys , multi , manipulate , write_concern , collation = collation )