# Connecting to a DB

#### Mongo DB

This endpoint will connect to a Mongo DB database. It will then query all documents from the "venues" collection and return them to the user.

![](/files/-Mhomfr0hdSIrmvQ5WKU)

{% hint style="info" %}
If you haven't already check out the [Hello World](/get-started/getting-started.md) endpoint.
{% endhint %}

\
To set it up:‌

1. Drag and drop a mongodb node and click on it to open the settings.&#x20;
2. If that's the first time you are viewing the settings of a mongodb node for this Diagram project, you will be asked for the mongodb connection URI. That authorises Diagram to access your MongoDB database. Set the query type to "Find" and "many" and the collection name to "venues" (or the name of your own collection).
3. Connect the request node from the "Params" port to the mongodb node on the "Options" port. As the mongodb node will query the whole collection we don't need any parameters. So it doesn't matter if we connect from the "Headers" port or the "Params" port and if we connect to "Filter" or "Options".
4. In a similar manner, connect the mongodb node from the "Out" port to the "Source" port of the response node.
5. Similarly, to the [*Hello World*](/get-started/getting-started.md#hello-world-endpoint) endpoint we can call this endpoint in the debug panel or by using the endpoint url in a frontend or in another nocode app.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ondiagram.com/get-started/connecting-to-a-db.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
