D toc |
---|
Excerpt | |
---|---|
You can create connections to MongoDB and MongoDB Atlas connections through
|
Supported Versions:
- Database versions: 2.6 - 5.0
Supported Environments:
Operation |
| Amazon | Microsoft Azure | |
---|---|---|---|---|
Read | Supported | Supported | Supported | |
Write | Not supported | Not supported | Not supported |
Prerequisites
- MongoDB supports basic (username/password) authentication.
Limitations
D s conn req sql |
---|
- This connection is read-only.
Create Connection
MongoDB
To create a MongoDB connection, please specify the following properties:
Property | Description | ||
---|---|---|---|
Host | Name of the host. | ||
Port | Set this value to the port number through which to access MongoDB. By default, this value is 27017. | ||
Database | The database that you want to read | ||
Auth Database | Name of the MongoDB database used for authentication | ||
Replica Set | (Optional) Comma-separated list of secondary servers in the replica set, specified by address and port. A replica set is a group of mongoDB processes that maintain the same data set. Replica sets provide redundancy and high availability and are the basis for all production deployments. For more information, see https://docs.mongodb.com/manual/replication/. | ||
Secondary Reads | Enable this checkbox if you want to read from secondary (slave) servers. | ||
Use SSL | Enable this checkbox if you want to connect using SSL. | ||
Connect String Options | (Optional) You can specify additional options used to connect as a string value. The following option sets the connection timeout in milliseconds:
The default value is | ||
Test Connection | After you have defined the connection credentials type, credentials, and connection string, you can verify that the
| ||
Default Column Data Type Inference | Set to | ||
Connection Name | Display name of the connection | ||
Connection Description | (Optional) Description of the connection, which appears in the application. |
MongoDB Atlas
To create a MongoDB Atlas connection, please specify the following properties:
Property | Description | ||
---|---|---|---|
Host | Name of the host. | ||
Port | Set this value to the port number through which to access MongoDB. By default, this value is 27017 . | ||
Database | The database that you want to read | ||
Replica Set | (Optional) Comma-separated list of secondary servers in the replica set, specified by address and port. A replica set is a group of mongoDB processes that maintain the same data set. Replica sets provide redundancy and high availability and are the basis for all production deployments. For more information, see https://docs.mongodb.com/manual/replication/. | ||
Secondary Reads | Enable this checkbox if you want to read from secondary (slave) servers. | ||
Connect String Options | (Optional) The option sets the connection timeout in milliseconds:
The default value is | ||
Test Connection | After you have defined the connection credentials type, credentials, and connection string, you can verify that the
| ||
Default Column Data Type Inference | Set to | ||
Connection Name | Display name of the connection | ||
Connection Description | (Optional) Description of the connection, which appears in the application. |
For more information on these settings, see http://cdn.cdata.com/help/RCF/jdbc/default.htm.
Create connection via API
Depending on your product edition, you can create connections of this type.
MongoDB:
Code Block |
---|
"vendor": "mongodb", "vendorName": "MongoDB", "type": "jdbc" |
MongoDB Atlas:
Code Block |
---|
"vendor": "mongodb_atlas", "vendorName": "MongoDB Atlas", "type": "jdbc" |
D s api refdoclink |
---|
operation/createConnection |
Connect string options
Connection timeout
By default, the supported driver applies a connection timeout to MongoDB of 0
seconds. As needed, you can modify the connection timeout through connect string options:
Code Block |
---|
Timeout=<value_in_seconds>; |
where:
<value_in_seconds>
corresponds to the number of seconds for the time.
Flattening Documents
Documents can contain other documents, which enables the storage of nested data. You can control the flattening of nested objects and arrays through the CData driver through Connect String Options.
Info |
---|
NOTE: Columns that have been flattened can be accessed or referenced using custom SQL queries. Additional information is below. |
Flatten Objects:
By default, the CData driver flattens nested Objects. As needed, you can set FlattenObjects to false
to disable this behavior.
For more information, see http://cdn.cdata.com/help/DGF/jdbc/RSBMongodb_p_FlattenObjects.htm.
Flatten Arrays:
By default, CData driver does not flatten Arrays.
- As needed, you can configure the number of elements that you want to have returned in your flattened arrays.
- To flatten all elements of all arrays, set FlattenArrays to
-1
.
For more information, see http://cdn.cdata.com/help/DGF/jdbc/RSBMongodb_p_FlattenArrays.htm.
Referencing flattened columns:
If you have flattened Objects or Arrays, you can reference these columns using square brackets in your custom SQL queries.
Example of flattened Object:
Code Block |
---|
SELECT [address.city] FROM my_table; |
Example of flattened Array:
Code Block |
---|
SELECT * FROM my_table WHERE [hobbies.0]='cricket'; |
Driver Information
For more information on CData JDBC drivers, see http://cdn.cdata.com/help/DGF/jdbc/default.htm.
Using MongoDB
MongoDB is a NoSQL document database that provides high performance, availability, and scalability.
MongoDB Data Organization Hierarchy
MongoDb has a two-level data hierarchy:
Code Block |
---|
+ Schema1 + Collection1 + Collection2 + Schema2 + Collection3 + Collection4 |
- Schema roughly corresponds to a database.
- Collection roughly corresponds to a table.
- A collection is composed of documents. A Document is a binary JSON representation of the fields and values of a row.
Database Uses
For more information on interacting with databases, see Using Databases.
Read Data
You can import datasets from MongoDB through the Import Data page. See Import Data Page .
Data Type Mappings
Info | ||||||
---|---|---|---|---|---|---|
NOTE: The
|
Access/Read
When data is imported from MongoDB, the supported data types from the source are converted to corresponding data types supported by the
D s webapp | ||
---|---|---|
|
Source Data Type | Supported |
| ||||
---|---|---|---|---|---|---|
ObjectId | Y | String | ||||
RegEx | Y | String | ||||
String | Y | String | ||||
Binary | Y | String | ||||
Integer | Y | Integer | ||||
Timestamp | Y | Datetime | ||||
Double | Y | Float | ||||
Array | Y | String | ||||
Bool | Y | bool | ||||
Null | Y | String | ||||
Date | Y | Datetime |
Write/Publish
Not supported.