def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def reorder_item(self, item, position):
    new_position = min(max(position, 0), len(self._items) - 1)