Get the first related model record matching the attributes or create it.

        :param attributes:  The attributes
        :type attributes: dict

        :rtype: Model

def first_or_create(
        self, _attributes=None, _joining=None, _touch=True, **attributes
    ):
        """
        Get the first related model record matching the attributes or create it.

        :param attributes:  The attributes
        :type attributes: dict

        :rtype: Model
        """
        if _attributes is not None:
            attributes.update(_attributes)

        instance = self._query.where(attributes).first()
        if instance is None:
            instance = self.create(attributes, _joining or {}, _touch)

        return instance