def save(self, doc):
        if doc.id:
            return self.update(doc)
        else:
            return self.insert(doc)
def _nearest_weekday(weekday):
    return datetime.now() + timedelta(days=(weekday - datetime.now().weekday()) % 7)