DEV Community

Rethan Kumar cv
Rethan Kumar cv

Posted on

MongoDB CRUD in the Shell — InsertMany, Update, Regex Count, Delete, and Top N Sort

Recently, I had the chance to work hands-on with MongoDB using a sample games dataset. This activity gave me a deeper understanding of how NoSQL databases operate, from storing and managing data to performing meaningful analysis.

Setting Up the Environment

I began by installing and running MongoDB Compass, which served as a user-friendly interface for database interaction. I created a new database called gameDB, where all the records would be stored and managed.

Importing the Dataset

The dataset was provided in JSON format and included details such as:

Game ID

Title

Genre

Rating

Review

Once imported, the data appeared neatly structured inside a collection, making it easy to explore.

Hands-On with CRUD Operations

🔹 Inserting Records
To get comfortable, I manually added 10 new game entries. This exercise helped me understand how MongoDB handles data insertion.

🔹 Querying the Data

Top 5 Games by Rating – I filtered and sorted the dataset to find the highest-rated games.

Keyword Search in Reviews – By searching for the term “good” in reviews, I explored how MongoDB manages text queries.

Fetching Reviews by Game ID – I retrieved reviews for a particular game, showing the power of targeted queries.

🔹 Updating & Deleting
I experimented with updating a review to reflect new feedback and deleting an outdated record. This highlighted MongoDB’s flexibility in handling dynamic data.

Exporting Results

After performing the queries, I exported results into JSON and CSV formats. This step was useful for sharing insights and conducting further analysis outside the database.

Key Learnings

Working with MongoDB on this dataset gave me valuable insights:

How CRUD operations (Create, Read, Update, Delete) work in a NoSQL environment

Ways to query, filter, and analyze unstructured data effectively

The ease of exporting results for external usage

Conclusion

This project showed me how MongoDB can be an excellent choice for handling semi-structured datasets like game reviews. It combines flexibility, scalability, and powerful querying features, making it well-suited for modern data-driven applications.






Top comments (0)