def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def deserialize(self, value):
        """Cast raw string to appropriate type."""
        return decode(value)