def save(
        self,
        upsert=False,
        validate=True,
        safe=False,
        **kwargs,
    ):
        """Saves the document to the database.

        If the document already exists, it will be updated, otherwise it will
        be created.

        Args:
            upsert (False): whether to insert the document if it has an ``id``
                populated but no document with that ID exists in the database
            validate (True): whether to validate the document
            safe (False): whether to ``reload()`` the document before raising
                any errors

        Returns:
            self
        """
        try:
            self._save(
                deferred=False,
                upsert=upsert,
                validate=validate,
                **kwargs,
            )
        except:
            if safe:
                self.reload()

            raise

        return self
Saves the document to the database.

        If the document already exists, it will be updated, otherwise it will
        be created.

        Args:
            upsert (False): whether to insert the document if it has an ``id``
                populated but no document with that ID exists in the database
            validate (True): whether to validate the document
            safe (False): whether to ``reload()`` the document before raising
                any errors

        Returns:
            self
        
fiftyone/core/odm/document.py