def remove_collection(self, collection_name): fcname = self.full_collection_name(collection_name) for doc in db[fcname].find(): if "file_id" in doc: fs.delete(doc["file_id"]) db.drop_collection(fcname) return True
def remove_user(userid): try: user = load_user(userid) db.drop_collection(user.list_collection_name) db.drop_collection(user.tile_collection_name) db.drop_collection(user.code_collection_name) user.delete_all_data_collections() # have to do this because of gridfs pointers user.delete_all_projects() # have to do this because of gridfs pointers db.drop_collection(user.project_collection_name) db.user_collection.delete_one({"_id": ObjectId(userid)}) return {"success": True, "message": "User successfully revmoed."} except Exception as ex: return process_exception(ex)
def delete_collection(self, collection_name): user_obj = current_user db.drop_collection(user_obj.full_collection_name(collection_name)) self.update_selector_list() return jsonify({"success": True})