def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def popitem(self):
        key, value = self._collection.popitem()
        return key, self._to_python(value)