DEV Community

Cover image for MongoDB: a complete guide
Ifeanyi Chima
Ifeanyi Chima

Posted on • Updated on

MongoDB: a complete guide

In programming, when working with a database, you need a language for querying and manipulating data. The most common language is SQL (structured query language).

MongoDB is a NoSQl (not only SQL) database. It is a non-relational database; it is a document-based database. This means data is stored in JSON format.

In MongoDB, data is called a record or a document. The documents have a key-value structure and look like JSON. Example:


{"name": "Lil baby"}

Enter fullscreen mode Exit fullscreen mode

All documents have a unique id. Documents are stored in collections, and a collection can hold many records. You need to use the collection name in your queries such as insert, retrieve and delete.

Commands

show dbs : This will show all the database on your server.

use testDB : This will create a new database.

show collections : This will show all the collections in a database.

db.dropDatabase() : This will delete a database.

Installation

To install the latest version of mongodb, click the link

MongoDB compass: This is a GUI you can install locally.

MongoDB Atlas: This is a cloud implementation of mongo.

Buy Me A Coffee

Thank you, Please follow me

HTML GitHub

Top comments (0)