0% found this document useful (0 votes)
36 views16 pages

Node JS Crud Operation in Mongoose

The document provides a detailed overview of CRUD operations using Mongoose with Node.js, including GET, POST, PUT, and DELETE APIs. It also outlines various training programs offered by HCL, including web development and programming languages, along with recent placement success stories. Additionally, it highlights the facilities provided, such as placement assistance and live project work.

Uploaded by

sudhanadar606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views16 pages

Node JS Crud Operation in Mongoose

The document provides a detailed overview of CRUD operations using Mongoose with Node.js, including GET, POST, PUT, and DELETE APIs. It also outlines various training programs offered by HCL, including web development and programming languages, along with recent placement success stories. Additionally, it highlights the facilities provided, such as placement assistance and live project work.

Uploaded by

sudhanadar606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

HCL (Higher Coding Language)

Node JS
Crud
Operations in
Mongoose

1 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
GET API in Mongoose
This is the connection file.

mongoose.js

const mongoose=require("mongoose")
mongoose.connect("mongodb://0.0.0.0:27017/HCL")

This is the schema and model file.

studentschema.js

const mongoose=require("mongoose")
const studentSchema=new mongoose.Schema({
rollno:Number,
name:String,
marks:Number
})
module.exports=mongoose.model("students",studentSchema)

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.get("/",async (req,resp)=>
{
const data=await student.find()
resp.send(data)
})
app.listen(5000)

Output

2 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)

POST API in Mongoose


index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.get("/",async (req,resp)=>
{
const data=await new
student({rollno:102,name:"Syam",marks:56})
const result=await data.save()
resp.send(result)
})
app.listen(5000)

Output

Output
3 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)

In above program we are inserting data manually now will use postman to insert
data.

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.post("/",async (req,resp)=>
{
const data=await new student(req.body)
const result=await data.save()
resp.send(result)
})
app.listen(5000)

Input

4 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)

Output

PUT API in Mongoose


index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.get("/",async (req,resp)=>
{
const data=await
student.updateOne({rollno:101},{$set:{name:"Golu"}})
resp.send(data)
})
5 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
app.listen(5000)

Output

Output

In above program we are Updating data manually now will use postman to insert
data.

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.put("/",async (req,resp)=>
{
const data=await
student.updateOne({rollno:req.body.rollno},{$set:req.body})
resp.send(data)
})
app.listen(5000)

6 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
Input

Output

DELETE API in Mongoose


index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.get("/",async (req,resp)=>
{
const data=await student.deleteOne({rollno:104})
resp.send(data)
7 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
})
app.listen(5000)

Output

In above program we are Deleting data manually now will use postman to insert
data.

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.delete("/",async (req,resp)=>
{
const data=await
student.deleteOne({rollno:req.body.rollno})
resp.send(data)
})
app.listen(5000)

We also use params to delete data.

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())

8 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
app.delete("/:rollno",async (req,resp)=>
{
const data=await student.deleteOne(req.params)
resp.send(data)
})
app.listen(5000)

Input

Search API
In search API we can search data with respect to any single field or multiple
fields.

mongoose.js

const mongoose=require("mongoose")
9 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
mongoose.connect("mongodb://0.0.0.0:27017/HCL")

This is the schema and model file.

studentschema.js

const mongoose=require("mongoose")
const studentSchema=new mongoose.Schema({
rollno:Number,
name:String,
marks:Number
})
module.exports=mongoose.model("students",studentSchema)

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.get("/:key",async (req,resp)=>
{
console.log(req.params.key)
const data=await student.find(
{
"$or":[
{ "name":{$regex:req.params.key}}
]
})
resp.send(data)
})
app.listen(5000)

10 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
Output

We can also search by other paramerte like rollno or marks

index.js

const express=require("express")
const app=express()
require("./mongoose")
const student=require("./studentschema")
app.use(express.json())
app.get("/:key",async (req,resp)=>
{
console.log(req.params.key)
const data=await student.find(
{
"$or":[
{"name":{$regex:req.params.key}},
{"rollno":{$regex:req.params.key}},
{"marks":{$regex:req.params.key}}
]
})
resp.send(data)
})
app.listen(5000)
11 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)

Higher Coding Language


Live Project Training With 100% Placement Assistance

S no Internship Content Duration


1 C,C++ with web development C,C++,html, CSS ,JS & Project 2 Months
2 Web Development html, CSS ,JS,Jquery,Bootstrap & Project 2 Months
3 C with DSA C and DSA 2 Months
4 C++ with DSA C++ and DSA 2 Months
5 Java with DSA Java and DSA 2 Months
6 Java With Mysql Core java and Mysql 2 Months
7 Front end html, CSS ,JS, React JS & Project 2 Months
8 Back end Node JS & Project 2 Months
9 Core java with Web html, CSS ,JS,Jquery,Bootstrap,Core Java & 3 Months
Development Project
10 Python with Web html, CSS ,JS,Jquery,Bootstrap,Python & 3 Months
Development Project
11 MERN Full Stack html, CSS ,JS,Jquery,Bootstrap,Node JS & 6 Months
Live Project
12 Java Full Stack html, CSS ,JS,Jquery,Bootstrap,Core 6 Months
Java,JDBC,JSP,Servlet & Live Project
13 Python Full Stack html, CSS ,JS,Jquery,Bootstrap,Core 6 Months
Python,Advanced Python,Django & Live
Project
14 Android Core Java and Android 4 Months
15 Fluter Dart and Flutter 4 Months
16 Collage Minor Project In any Technology NA
17 Collage Major Project In any Technology NA
18 Python With ML Core Python, Advanced 6 months
Python,Numpy,Pandas, Mitlab, Seaborn &

12 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
ML Algortithms
19 Python With AI Core Python, Advanced 6 months
Python,Numpy,Pandas, Mitlab, Seaborn &
AI Algortithms
20 Python Data science Core Python, Advanced 6 months
Python,Numpy,Pandas, Mitlab, Seaborn &
Data Science Algortithms
20 Python Data Analytics Core Python, Advanced 6 months
Python,Numpy,Pandas, Mitlab, Seaborn
,mysql and power BI

Our Recent Placements

Name Photo Company PKG


Khusbu Dubey TCS 3.59 LPA

Prashant Shukla Infosys 3.50 LPA

Tanuja Patidar BestPeers 2.0 LPA

Sneha Gupta Cyber Intant NA

13 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
Rohan Sisodiya GeeCom India 1.2 LPA

Kanchan pandey SheThink 1.8 LPA

Sachin Choudhary Nokia 4.0 LPA

Shaikhar parmar Capgemini 3.80 LPA

Lakhan Patel TCS 5.00 LPA

Kundan Mandloi Maveric Systems 2.88 LPA

Yoegsh Deloitte 3.20 LPA

14 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
Dheeraj Patel Cognizant 4.50

Rahul Digiprima 1.9 LPA

Jayendra Assistant 2.4 LPA

Sachin Codernaline 1.60 LPA

Sanchit Avery Bit 1.80 LPA

Sumit Geecom India 1.20 LPA


Chandravanshi

15 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary
HCL (Higher Coding Language)
Ajay Sailani Avery Bit 1.20 LPA

Other Facility

 100% Placement Assistance


 Live Coding
 Highly Experience Industrial Trainer
 Work on Live Project
 Free Printed Notes
 2 Days Free Demo
 Mock Interview
 Certificate of Internship
 1000 Rs Referral Amount
 Corporate Environment
 Lab Facility Available
 May Be Contact for Placement
 Offline Training also available

Contact No – 82368 09542, 75662 99542

Add - 109,208 Prem Plaza, Ashok Nagar,Bhwarkua, Indore – 452001 (M.P.)

16 109 1st Floor, 208 2nd Floor, Prem Plaza, Ashok Nagar, Bhawarkua, Indore(M.P.)
Mob - 82368 09542, 75662 99542 Copyright © Arvind Choudhary

You might also like