Professional Documents
Culture Documents
1-MongoDB (3 Files Merged)
1-MongoDB (3 Files Merged)
1-MongoDB (3 Files Merged)
==================
MongoDB Database
Node.js Server Side Technology
Express Middleware
Database
========
- Application needs data.
- Data can be stored in a file or in database.
- Relational Data and Scalable Data
- Various database
- Oracle
- MySql
- Sql Server
- MongoDB
https://www.mongodb.com/try/download/community
run => services.msc => MongoDB server => Right Click => Start
MongoDB Compass
================
1. open MongoDB Compass from programs
mongodb://127.0.0.1:27017
4. click "connect"
1. Conceptual Model
2. Physical Model
3. Logical Model
4. Entity Model [ER Diagram]
MongoDB Commands
[CRUD]
C - Create
R - Read
U - Update
D - Delete
RDBMS MongoDB
[Oracle|MySql]
--------------------------------------------
Database Database
Tables Collections
Records Documents
Fields Fields
2. Commands
> db.createCollection("tblcategories");
> db.createCollection("tblproducts", { })
option type description
---------------------------------------------------------------------
autoIndexId boolean It will add an auto id when set to true.
> db.createCollection("tblproducts")
> db.createCollection("tblcategories", {autoIndexId:true, max:10,
capped:true, size:2097152})
Ex:
> db.tblcategories.insertOne({CategoryId:1, CategoryName:"Electronics"})
> db.tblproducts.find().pretty()
Querying
{ProductId:2} Equal To
{Name:"Nike Casuals"}
{Price: {$gt:10000} } Greater than
{Price: {$gte:10000} } Greater than or equal
{Price: {$lt:10000} } Less than
{Price: {$lte:10000} } Less than or equal
{Price: {$ne:10000} } Not equal
Querying Document
- find({ })
- Query Operators
$gt >
$lt <
$gte >=
$lte <=
$ne !=
$in find value in array, property in object
$and AND
$or OR
$not NOT
{
$and:[{Price:{$gt:4000}}, {Price:{$lt:10000}},
{Category:"Electronics"}]
}
Ex:
>
db.tblproducts.find({$and:[{Price:{$gt:4000}},{Price:{$lt:10000}}]}).pret
ty()
> db.tblproducts.find({Cities:{$in:["Hyd"]}}).pretty()
Update Queries
---------------------
updateOne()
updateMany()
Operators:
$set : changes the value
$rename : change the field name
$unset : remove the field
Syntax:
db.collection.updateOne({findQuery}, { updateQuery})
Ex:
> db.tblproducts.updateOne({ProductId:3},{$set:{Price:3500.55}})
> db.tblproducts.updateMany({}, {$set:{Stock:true}})
EX:
updateMany(
{
$and:[ {Price:{$gt:5000}}, {Price:{$lt:10000}} ]
},
{
$set: {Stock:true}
}
)
> db.tblproducts.updateMany({},{$rename:{Cities:"ShippedTo"}})
> db.tblproducts.updateMany({},{$unset:{Cities:" "}})
Delete Query
-------------------
deleteOne()
deleteMany()
Syntax:
db.tblproducts.deleteOne({findQuery});
db.tblproducts.deleteMany({ShippedTo:{$in:["Delhi"]}})
db.tblcategories.deleteOne({CategoryId:3})
IEEE Project
[ I-Shop - Shopping ]
https://ieeexplore.ieee.org/document/7941952
https://sci-hub.hkvisa.net/
1. Abstract
3 to 4 line summary
2. Existing System
points
3. Proposed System
points