Logo
MongoDB
Technology

MongoDB

Learn about NOSQL and mongoDB and connection with express.js

1 min read
Article
Database
SQL
RDBMS

Table of Contents

SQL vs NoSQL

  • SQL are Relational Databases whereas, NoSQL are non-relational or distributed database. Popular SQL databases
  • MySQL
  • PostgreSQL
  • SQLite

Popular NoSQL Databases

  • MongoDB
  • Redis
  • Amazon DynamoDB

MongoDB

  • A popular NoSQL database
  • Datas are stored in the form of key-value pair.

Inserting :

  • In mongoDB, objects are stored in a collection, To create a collection: db.createCollection("cats")

    • This will create a collection named 'cats'
  • To insert datas(objects) into the mongoDB collection, 2 methods can be used

      1. `db.insertOne({document})`
      2. `db.insertMany({documents})`
    
    • Examples:
db.insertOne({
	name : "siamese",
	gender : "female",
	age : 3
	})
db.insertMany([
{
name : "Persian",
gender : "male",
age : 2
},
{
name : "Russian",
gender : "male",
age : 8
}]
	)

Finding :

  • In mongoDB, objects inside the collections can be accessed by using the find() method.
  • To find everything in the collection, db.cats.find() -> This results in every documents present in the collection named cats.

Published on January 20, 2025

Estimated reading time: 1 minutes

Share this article: