def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def serialize(self, value, display=False):
        if value is None:
            return ""
        return encode(value)