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

# Connect to MongoDB

> Learn how to connect with MongoDB

MongoDB is a NoSQL database designed to store and retrieve unstructured or semi-structured data using BSON documents.

## Prerequisites

When you create a MongoDB connection in Prophecy, access permissions are tied to the credentials you use. This is because Prophecy uses your credentials to execute all data operations, such as reading from or writing to collections.

To fully leverage a MongoDB connection in Prophecy, you need the following MongoDB permissions:

* `Read` from the collection defined in the connection
* `Write` to the collection defined in the connection

## Feature support

The table below outlines whether the connection supports certain Prophecy features.

| Feature                                                                                    | Supported |
| ------------------------------------------------------------------------------------------ | --------- |
| Read data with a [Source gem](/data-analysis/gems/source-target/external-table/mongodb)    | Yes       |
| Write data with a [Target gem](/data-analysis/gems/source-target/external-table/mongodb)   | Yes       |
| Browse data in the [Environment browser](/data-analysis/development/studio/studio#sidebar) | Yes       |
| Index tables in the [Knowledge Graph](/data-analysis/ai/knowledge-graph/knowledge-graph)   | No        |

## Connection parameters

To create a connection with MongoDB, enter the following parameters:

| Parameter                                                                | Description                                                                                                   |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| Connection Name                                                          | Name to identify your connection                                                                              |
| Protocol                                                                 | Protocol to use to communicate to the database<br />Example:`mongodb+srv` for cloud-hosted clusters           |
| Host                                                                     | Where your MongoDB instance runs<br />Example:`cluster0.<cluster-name>.mongodb.net` for cloud-hosted clusters |
| Username                                                                 | Username for your MongoDB instance                                                                            |
| Password ([Secret required](/data-analysis/environment/secrets/secrets)) | Password for your MongoDB instance                                                                            |
| Database                                                                 | Default database for reading and writing data                                                                 |
| Collection                                                               | Collection to use for the connection                                                                          |

## Data type mapping

When Prophecy processes data from MongoDB using SQL warehouses, it converts MongoDB-specific data types to formats compatible with your target warehouse. This table shows how [MongoDB data types](https://www.mongodb.com/docs/manual/reference/bson-types/) are transformed for Databricks, BigQuery, and Snowflake.

| MongoDB                                                                                     | Databricks                          | BigQuery                               | Snowflake                         |
| ------------------------------------------------------------------------------------------- | ----------------------------------- | -------------------------------------- | --------------------------------- |
| 32-bit integer                                                                              | `int`<br />Alias: Integer           | `int64`<br />Alias: Integer            | `number`<br />Alias: Number       |
| 64-bit integer                                                                              | `bigint`<br />Alias: Bigint         | `int64`<br />Alias: Integer            | `number`<br />Alias: Number       |
| Double                                                                                      | `double`<br />Alias: Double         | `float64`<br />Alias: Float            | `float`<br />Alias: Float         |
| Boolean                                                                                     | `boolean`<br />Alias: Boolean       | `bool`<br />Alias: Boolean             | `boolean`<br />Alias: Boolean     |
| String                                                                                      | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| Date                                                                                        | `timestamp`<br />Alias: Timestamp   | `timestamp`<br />Alias: Timestamp      | `timestamp`<br />Alias: Timestamp |
| Timestamp                                                                                   | `timestamp`<br />Alias: Timestamp   | `timestamp`<br />Alias: Timestamp      | `timestamp`<br />Alias: Timestamp |
| Binary                                                                                      | `binary`<br />Alias: Binary         | `bytes`<br />Alias: Bytes              | `binary`<br />Alias: Binary       |
| ObjectId                                                                                    | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| Decimal128                                                                                  | `decimal(34,2)`<br />Alias: Decimal | `bignumeric(34,2)`<br />Alias: Numeric | `number(34,2)`<br />Alias: Number |
| Min key                                                                                     | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| Max key                                                                                     | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| Regular Expression                                                                          | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| DBPointer                                                                                   | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| JavaScript                                                                                  | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| JavaScript with scope                                                                       | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| Symbol                                                                                      | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| [Embedded Document](https://www.mongodb.com/docs/manual/tutorial/query-embedded-documents/) | `struct`<br />Alias: Struct         | `struct`<br />Alias: Struct            | `variant`<br />Alias: Variant     |
| Array                                                                                       | `array`<br />Alias: Array           | `array`<br />Alias: Array              | `array`<br />Alias: Array         |
| Empty Array                                                                                 | `array`<br />Alias: Array           | `array`<br />Alias: Array              | `array`<br />Alias: Array         |
| Null                                                                                        | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |
| Unidentified                                                                                | `string`<br />Alias: String         | `string`<br />Alias: String            | `string`<br />Alias: String       |

<Info>
  Embedded MongoDB documents are inferred as Snowflake `VARIANT` values when read through the Spark MongoDB connector. Although Snowflake supports the `OBJECT` type, inferred embedded documents map to `VARIANT` unless explicitly declared otherwise.
</Info>

<Info>Learn more in [Supported data types](/data-analysis/gems/data-types).</Info>

## Sharing connections within teams

Connections in Prophecy are stored within [fabrics](/data-analysis/environment/fabrics/prophecy-fabrics), which are assigned to specific teams. Once a MongoDB connection is added to a fabric, all team members who have access to the fabric can use the connection in their projects. No additional authentication is required—team members automatically inherit the access and permissions of the stored connection credentials.

<Warning>
  Be mindful of the access level granted by the stored credentials. Anyone on the team will have the same permissions—including access to sensitive data if allowed.

  To manage this securely, consider creating a dedicated fabric and team for high-sensitivity connections. This way, only approved users have access to those credentials.
</Warning>
