def save(self): if (self.name is not None): if hasattr(self, "_id"): Database.replace(Database.COLLECTIONS.BOT, self.toDict()) else: self._id = Database.insert(Database.COLLECTIONS.BOT, self.toDict()) else: raise Exception("Bot can't be saved without name.")
def save(self): if (self.text is not None): if hasattr(self, "_id"): Database.replace(Database.COLLECTIONS.SENTENCE, self.to_dict()) else: self._id = Database.insert(Database.COLLECTIONS.SENTENCE, self.to_dict()) self.data = self.to_dict() else: raise Exception("Category can't be saved without name.")
def save(self): if(self.name is not None): self.sentence_ids = [] for s in self.sentences: s.save() self.sentence_ids.append(s._id) if hasattr(self, "_id"): Database.replace(Database.COLLECTIONS.CATEGORY, self.toDict()) else: self._id = Database.insert(Database.COLLECTIONS.CATEGORY, self.toDict()) self.isSaved = True self.data = self.toDict() else: raise Exception("Category can't be saved without name.")