Example #1
0
def trees_json():
    """
    List tree objects in JSON format
    """
    trees = []
    for tree in TreeDB.objects:
        trees.append(Tree.from_mongo(tree))
    return trees
Example #2
0
def get_tree(oid: str):
    """
    Retrieve tree from DB
    """
    try:
        selected_tree = TreeDB.objects.get(id=oid)
        return Tree.from_mongo(selected_tree)
    except TreeDB.DoesNotExist:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND, detail="Object ID not found"
        )