Skip to content

Zio.Mongo()

Read‑only. This is a place to view collected data, so writing is not possible — if you look at another set and infer from Zio.mongo(...).create(...) that there is none. To compare with the net, see the table in Zio.Database (Overview).

MongoDB databases can be queried easily for dynamically created user-defined collection data and retrieved as a GraphResult object.

Method Description
Zio.mongo(collection_name) Retrieves user-defined collection data created in MongoDB and returns it in the form of a GraphResult.
from zio_ontology import Zio
from fastapi import FastAPI
from fastapi.responses import JSONResponse
app = FastAPI()
@app.get("/api/mongo/{collection}")
async def run_mongo(collection: str):
result = Zio.mongo(collection)
return JSONResponse(content={"data": result.data})

You will get a LookupError — it says “there is no such collection”, not “no data”. If you conflate the two, a typo in the name may be interpreted as an “empty result”, so callers keep trying by slightly changing the name. Collections are created by the collection pipeline — they cannot be created here.

Therefore do not guess the name; first call Zio.mongo.list(). It returns [{name, description, columns[]}] — only readable collections appear, so a missing name will also raise a LookupError in Zio.mongo().