async def load_pipeline_graph_by_user(current_user: User = Depends(deps.get_current_user)):
    user_id = current_user.userId
    result = load_pipeline_graph(user_id)
    if result is None:
        return PipelinesGraphics()
    else:
        return result
async def save_pipeline_graph(pipeline_graph: PipelinesGraphics, current_user: User = Depends(deps.get_current_user)):
    user_id = current_user.userId
    result = load_pipeline_graph(user_id)
    pipeline_graph.userId = user_id
    if result is not None:
        return update_pipeline_graph(pipeline_graph, user_id)
    else:
        return create_pipeline_graph(pipeline_graph)
def update_pipeline_graph(pipeline_graph, user_id):
    pipeline_graph_collection.update_one({"user_id": user_id}, {"$set": pipeline_graph.dict()})
    return PipelinesGraphics.parse_obj(pipeline_graph)
def load_pipeline_graph(user_id):
    result = pipeline_graph_collection.find_one({"userId": user_id})
    if result is None:
        return None
    else:
        return PipelinesGraphics.parse_obj(result)
def create_pipeline_graph(pipeline_graph: PipelinesGraphics):
    pipeline_graph_collection.insert(pipeline_graph.dict())
    return PipelinesGraphics.parse_obj(pipeline_graph)