def remove_item(self, itemId): query = {'_id': self._id} document = {'items': {'_id': itemId}} Database.delete_one_from_array(Checklist.collection, query, document) cursor = Database.find_one(Checklist.collection, query) isRemovedtItemExist = list( filter(lambda c: c['_id'] == itemId, cursor['items'])) if len(isRemovedtItemExist) == 0: return True return False
def delete_attachment(self, fileId): query = {'_id': self._id} toRemoveFile = {'attachments.files': fileId} isRemoveFromFs = FS.delete(fileId) try: if isRemoveFromFs: if fileId == self.attachments['assigned']: clearAssignment = {'attachments.assigned': ''} Database.update_one(Card.collection, query, clearAssignment) Database.delete_one_from_array(Card.collection, query, toRemoveFile) return {**query, 'forList': self.forList, 'deletedFile': fileId} except: raise "The file is not exist with — {} | id".format(fileId)
def remove_board(cls, teamId, board): Database.delete_one_from_array('teams', {"_id": teamId}, {"boards": board})
def remove_comment(self, commentId): query = {'_id': self._id} removeComment = {'comments': commentId} Database.delete_one_from_array(Card.collection, query, removeComment)
def remove_checklist(self, checklistId): Database.delete_one_from_array('cards', {'_id': self._id}, {'checklists': checklistId})