def delete(self): Database.delete(collection="user", query={"_id": self._id})
def find_one_class_username(cls, username): user_data = Database.find_one(collection="user", query={"username": username}) return cls(**user_data)
def update_one(self, data): Database.update_one(collection="user", query={"_id": self._id}, data={'$set': data})
def find_one_class_id(cls,id): user_data = Database.find_one(collection="user", query={"_id": id}) return cls(**user_data)
def find_one_username(username): return Database.find_one(collection="user", query={"username": username})
def find(): return [user for user in Database.find(collection="user")]
def find_one_id(id): return Database.find_one(collection="user", query={"_id": id})
def delete(self): Database.delete(collection="document", query={"_id": self._id})
def save_to_mongo(self): Database.insert(collection='user', data=self.get_json())
def find_by_author(author_id): return [ doc for doc in Database.find(collection="document", query={"author_id": author_id}) ]
def find_one_class_id(cls, id): doc_data = Database.find_one(collection="document", query={"_id": id}) return cls(**doc_data)
def find_one_id(id): return Database.find_one(collection="document", query={"_id": id})
def find(): return [doc for doc in Database.find(collection="document")]
def save_to_mongo(self): Database.insert(collection='document', data=self.json_data())