how to insert multiple records using post man api| nodejstutorials

using below method

u can insert many records at a time using one api

create many api

app.post('/create-many',async (req, res)=> {
let body = req.body;

PERSON_SCHEMA.insertMany(body).then(result =>
{
res.send({sts:200,msg:'created'})
}).catch(err => {
res.send("faile")
})
})


post man data

api http://localhost:3000/create-many

[

{
"fname": "one",
"lname": "onel",
"mno": "one mobile",
"addr": "one addr"
},
{
"fname": "two",
"lname": "twol",
"mno": "two mobile",
"addr": "two addr"
},
{
"fname": "two",
"lname": "twol",
"mno": "two mobile",
"addr": "two addr"
},
{
"fname": "two",
"lname": "threel",
"mno": "three mobile",
"addr": "three addr"
}
]

hit on api it willl insert into databse


No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...