0% found this document useful (0 votes)
2 views

MongoDB

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MongoDB

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MONGODB

1. What is MongoDB? V. IMP.


MongoDB is a popular open-source, NoSQL database management system.
Instead of storing data in tradi onal table structures as in rela onal
databases, MongoDB stores data in JSON-like documents.

2. When to use RDBMS and when to use NoSQL DB in your applica ons?

RDBMS are suitable for applica ons that require complex transac ons
and data integrity(ACID), such as banking, finance, and e-commerce.

NoSQL databases are designed to handle large volumes of data with


high-speed read and write opera ons, such as social media, loT, and
gaming.

3. What are Documents and Collec ons in NoSQL?


A document is a semi-structured data structure (XML, JSON format) that
stores informa on in a NoSQL database. It is similar to a row in a table in
a RDBMS.
A "collec on" is a group of documents that are stored together in a
NoSQL database. It is similar to a table in a RDBMS.

4. What are CRUD opera ons in MongoDB?


5. What are Query Operators in MongoDB? V. IMP.
Query operators are special keywords or symbols used to perform
opera ons like comparison, logical opera ons in queries.

6. What is Mongoose?
Mongoose is a library for MongoDB that is used to connect node.js and
MongoDB it also provides some func ons like
 FindbyId
 Findbyidand Update
 Findbyidandcreate
 Delete many
 Delete one Create (C):
 Find one
Adds new data to the system or
 Find one and update database.
 Find one and delete Example: Adding a new user to a
database or creating a new blog post.
Read (R):

Retrieves or fetches data from the


const mongoose = require("mongoose"); system or database.
require("dotenv").config(); Example: Viewing a list of users or
fetching details of a specific product.
exports.connect = () => { Update (U):
mongoose
.connect(process.env.DATABASE_URL, { Modifies existing data in the system or
useNewUrlparser: true, database.
Example: Changing a user's email
useUnifiedTopology: true, address or updating the price of a
}) product.
.then(console.log(`DB Connection Success`)) Delete (D):
.catch((err) => {
console.log(`DB Connection Failed`); Removes data from the system or
database.
}); Example: Deleting a user or removing
a blog post.
};

You might also like