Providers

MongoDB

api.storage.connect({ type: "database", provider: "mongodb", endpoint })

A document database of your own. Nine read actions, four write actions, and the collections you already have — nothing is renamed and nothing is migrated.

type: database9 reads · 4 writesconnection pooled
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

This is the richest of the connected providers, and the one the agent tools were shaped around: a database it has never seen can be mapped, queried and written to without a schema being declared anywhere.

Connecting

const db = await api.storage.connect({
  label: "Production",
  type: "database",
  provider: "mongodb",
  endpoint: { credentials: { uri: "mongodb+srv://user:password@cluster.example.net/shop" } },
});
db = api.storage.connect(
    label="Production",
    type="database",
    provider="mongodb",
    endpoint={"credentials": {"uri": "mongodb+srv://user:password@cluster.example.net/shop"}},
)
credentials.uristringrequired

The connection string. It carries the password, so it belongs in credentials, which is encrypted at rest.

The database name is the path of the URI

…/shop is what picks the database. A URI with no path lands on a default one, which reads as empty — that is the usual explanation for « my collections are missing ».

What run() accepts

ActionReads or writesNeeds collection
overviewreadno
collectionsreadno
schemareadyes
findreadyes
countreadyes
aggregatereadyes
searchreadno
insertwriteyes
updatewriteyes
deletewriteyes
savewriteyes
createCollectionwriteyes
dropCollectionwriteyes

Anything else raises Action MongoDB inconnue. tables, execute, list, object and upload belong to other providers.

_id may be a string

An identifier written as a 24-character string is turned into an ObjectId wherever one is expected: direct equality, $in, $nin and $ne. That is what lets an identifier travel through JSON — out of a find, into a form, back into an update — without a cast of yours in between.

const [order] = await db.run({ action: "find", collection: "orders", options: { limit: 1 } });

// order._id arrived as a string; it goes back as one
await db.run({
  action: "update",
  collection: "orders",
  filter: { _id: order._id },
  update: { $set: { status: "shipped" } },
});
order = db.run(action="find", collection="orders", options={"limit": 1})[0]

# order["_id"] arrived as a string; it goes back as one
db.run(
    action="update",
    collection="orders",
    filter={"_id": order["_id"]},
    update={"$set": {"status": "shipped"}},
)

Five operators are refused

$where, $function and $accumulator run JavaScript inside the database; $out and $merge write somewhere other than where you are looking. All five are refused on find, count, update, delete and aggregate, by inspecting the filter or the pipeline you sent.

await db.run({ action: "find", collection: "users", filter: { $where: "this.age > 30" } });
// Error: find : l'operateur $where n'est pas autorise.
db.run(action="find", collection="users", filter={"$where": "this.age > 30"})
# IaGenifyError: find : l'operateur $where n'est pas autorise.

Bounds that are imposed

ThingBound
aggregate result500 documents
aggregate and count duration30 seconds
insert batch1 to 500 documents
overview30 collections, 25 fields, 1 sample each
schema20 recent documents, 150 fields

An empty filter is refused on a write

all: true is the way to say you meant it

update and delete with no filter would touch every document, so they stop unless you add all: true. Reads have no such guard — an empty filter on find is an ordinary query.

The connection is kept

One client per URI is held and reused across calls, so the second run() does not reconnect. A URI that changes — a rotated password, a new host — is a new connection: it does not inherit the old one.

System collections are filtered out

collections and overview leave out anything in the system. namespace. What you see is what you put there.