---
title: "MongoDB as a Source"
slug: "mongodb-as-a-source"
description: "Send data to MongoDB easily with Dataddo. Learn how to add MongoDB as a source or destination. Configure snapshotting preferences and more. Contact us for help."
tags: ["Custom-schema connector", "How-to guide", "Data source"]
updated: 2024-02-13T14:58:04Z
published: 2024-02-13T14:58:04Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dataddo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB as a Source

**MongoDB** is an open-source NoSQL database management system that provides a flexible, document-oriented approach to storing and retrieving data. It is designed to handle unstructured or semi-structured data and is widely used for building scalable and high-performance applications.

## Authorize the Connection to MongoDB

In order to connect MongoDB as a ***data source***, you will need to first [authorize the connection to your MongoDB](/docs/mongodb#authorize-the-connection-to-mongodb).

## Create a MongoDB Data Source

1. On the **Sources** page, click on the [**Create Source**](https://app.dataddo.com/sources/new) button and select the connector from the list.
2. From the drop-down menu, choose your **account**.
          **Didn't find your account?**

          

Click on **Add new Account** at the bottom of the drop-down and follow the on-screen prompts. You can also go to the **Authorizers** tab and click on [**Add New Service**](https://app.dataddo.com/service/new).
3. **Name** your data source and fill in the following fields:
  1. **MongoDB Collection**: Name of the collection from your Mongo database, please note that this field is **case-sensitive**. E.g. Here we want to use a collection named `Box`.  

![MongoDB - collection](https://cdn.document360.io/084ed225-3f99-4644-a2da-39ca0cd5ef45/Images/Documentation/MongoDB%20-%20collection.png)
  2. **Aggregation pipeline**: Use json format transformation, e.g.  

![Mongo DB - json example](https://cdn.document360.io/084ed225-3f99-4644-a2da-39ca0cd5ef45/Images/Documentation/Mongo%20DB%20-%20json%20example.png)
4. Configure your **snapshotting preferences**. Choose your [**sync frequency**](https://docs.dataddo.com/docs/extraction#extraction-frequency) or the exact synchronization time under **Show advanced settings**.
          **DATADDO TIP**

          

If you need to **load historical data**, please refer to the [**Data Backfilling**](https://docs.dataddo.com/docs/data-backfilling) article.
5. Preview your data by clicking on the **Test Data** button in the top right corner. You can **adjust the date range** for a more specific time frame.
6. Click on **Save** and **congratulations, your new data source is ready!**

---

## Troubleshooting

### Context Deadline Exceeded Error

**ERROR CODE**

```
rpc error: code = DeadlineExceeded desc = context deadline exceeded
```

This issue may be caused by extracting data over an **extended timeframe**. Use `WHERE` or `LIMIT` clauses in your SQL query to manage the size and scope of the data extraction.

1. Use `WHERE` to specify the date range.

```
SELECT * FROM your_table
WHERE date_column BETWEEN '202X-01-01' AND '202X-01-31';
```
2. Use `LIMIT` to specify the specify the maximum number of records to return.

```
SELECT * FROM your_table
LIMIT 1000;
```
3. Combine `WHERE` and `LIMIT` for more precise control. The query in this example will return the first 1000 records where the date is after January 1, 202X.

```
SELECT * FROM your_table
WHERE date_column > '202X-01-01'
LIMIT 1000;
```

## Related Articles

Now that you have successfully created a ***data source***, see how you can connect your data to a dashboarding app or a data storage.

**Sending Data to Dashboarding Apps**

- [Simple Data Integration to Dashboards](https://docs.dataddo.com/docs/simple-data-integration-to-dashboards)
- [Data Backfilling to Dashboarding Apps](https://docs.dataddo.com/docs/data-backfilling-to-dashboarding-apps)

**Sending Data to Data Storages**

- [Batch Ingestion to Data Warehouses](https://docs.dataddo.com/docs/ingestion-to-data-warehouses)
- [Data Backfilling to Storages](https://docs.dataddo.com/docs/data-backfilling-to-storages)

**Other Resources**

- [Troubleshooting](https://docs.dataddo.com/docs/troubleshooting)
- [Extraction Logs](https://docs.dataddo.com/docs/extraction-logs)
- [Data Duplication](https://docs.dataddo.com/docs/data-duplication)
