def to_serializable_dict(self, mask_secrets=False):
        """
        Serialize database model to a dictionary.

        :param mask_secrets: True to mask secrets in the resulting dict.
        :type mask_secrets: ``boolean``

        :rtype: ``dict``
        """
        serializable_dict = {}
        for k in sorted(six.iterkeys(self._fields)):  # pylint: disable=E1101
            v = getattr(self, k)
            if isinstance(v, JSON_UNFRIENDLY_TYPES):
                v = str(v)
            elif isinstance(v, me.EmbeddedDocument):
                # TODO: Allow overriding json_options.uuid_representation via cfg
                v = json_decode(v.to_json(json_options=LEGACY_JSON_OPTIONS))

            serializable_dict[k] = v

        if mask_secrets and cfg.CONF.log.mask_secrets:
            serializable_dict = self.mask_secrets(value=serializable_dict)

        return serializable_dict

        Serialize database model to a dictionary.

        :param mask_secrets: True to mask secrets in the resulting dict.
        :type mask_secrets: ``boolean``

        :rtype: ``dict``
        
st2common/st2common/models/db/stormbase.py