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