get one usng findone
app.get('/get-one-await',async (req, res)=> {
let params = req.query.id;
let listDetails= await PERSON_SCHEMA.findOne({id:params}).sort({_id:-1});
res.send(listDetails);
})
app.get('/get-by-id',async (req, res)=> {
let body = req.body;
PERSON_SCHEMA.find({fname: {$eq: body.name}}).then(result =>
{
res.send(result)
}).catch(err => {
res.send("faile")
})
})
app.get('/get-by-id-one',async (req, res)=> {
let body = req.body;
PERSON_SCHEMA.findOne({fname: {$eq: body.name}}).then(result =>
{
res.send(result)
}).catch(err => {
res.send("faile")
})
})
http://localhost:3000/get-by-id-one
No comments:
Post a Comment