MongoDB
The mongo_query function lets you execute queries against a MongoDB database from your bot workflow. Work with documents, collections, and flexible data structures.
Parameters
| Parameter | Description |
|---|---|
uri |
MongoDB connection string |
database |
Database name |
collectionName |
Collection name |
query |
Query (JSON) |
save_as |
Variable name for the result |
Examples
Finding a Document
{
"uri": "mongodb+srv://user:pass@cluster.mongodb.net",
"database": "myapp",
"collectionName": "users",
"query": {"telegram_id": "{=tgData.from.id=}"},
"save_as": "user"
}
Using the Result
After executing the query, data is available via the variable:
Hello, {=user.name=}! Your balance: {=user.balance=}
Use Cases
- Flexible user data storage
- Catalogs with arbitrary structure
- Action logging
- Session and state storage