Skip to main content

MongoDB

MongoDB is a popular open-source document-oriented NoSQL database that is designed for high scalability, performance, and availability. Unlike traditional relational databases, MongoDB stores data in flexible, semi-structured JSON-like documents instead of rigid rows and columns. This allows for a more agile and dynamic data modeling process, which can better accommodate changing data requirements.

Connecting to the Database

Mammoth allows you to connect to your Database and get the data into Mammoth.

  1. Select API & Databases from the "Add Data" menu and click on MongoDB.
  1. Create a new connection and add your database credentials - Host URL, Port, Username, Password.
  1. Once the connection is established, you will be presented with a list of tables and views in that database.
  • Select the desired table to get a preview.
  • Write your own SQL query or run a test query and preview the result.
  • Click on Next

After you have selected the table you want to work on, you get options to schedule the data imports as discussed below.

Scheduling your Data Pulls

You can start retrieving the data now or at a specific time according to your choice. You can also schedule the data pull in order to get the latest data from your Database at a certain time interval - just once, daily, weekly or monthly.

On every data pull from your Database, you also have an option to - Replace all data, Add new data since last pull, and Replace with new data since last pull.

On choosing Add new data since last pull or Replace with new data since last pull option, you will get an option to choose a unique sequence column. Using this column, on refresh, Mammoth will pick up all the rows that have greater value in this column than the previous data pull.

note
  1. Make sure that Mammoth's public IP address is added to your whitelist.
  2. Mammoth's public IP is displayed on the create connection window.
  3. MongoDB stores data as documents and collections. Documents are analogous to JSON objects but exist in the database in a more type-rich format known as BSON. A group of documents is called a Collection. When importing from MongoDB, the documents are converted to tables (rows and columns).
  4. The columns (keys from documents) are created by looking at the first 100 documents in a collection.

For example: If the documents in a collection X are as follows

{ "name": "Aisha", "student_id": 1 }
{ "name": "Riya", "student_id": 2, "college": "BVB" }

The converted table in Mammoth will look like the following:

namestudent_idcollege
Aisha1
Riya2BVB

Further, if the document has nested json/array

{
"name": "Aisha",
"student_details": {
"id": 1,
"college": "BVB",
"date_of_graduation": "2022-08-11T18:30:00.000Z",
"branch": "E&C",
"subjects": [
{
"subject": "Embedded Systems",
"credits": 6
},
{
"subject": "VLSI Design",
"credits": 6
}
]
}
}

The converted table in mammoth will look something like this:

namestudent_details
Aisha{ "id": 1, "college": "BVB", "date_of_graduation": "2022-08-11T18:30:00.000Z", "branch": "E&C", "subjects": [{"subject": "Embedded Systems", "credits": 6}, {"subject": "VLSI Design", "credits": 6} ]}

You can use the Extract JSON function in Mammoth to easily convert this into rows and columns.