skip to Main Content

Mongodb – how to send data to mongo via URL?

i post data to mongodb as following: app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended:true})); app.use('/insert',async(req,res)=>{ const newProduct=new product({ _id:req.body._id, name:req.body.name, description:req.body.description }); try{ await newProduct.save(); // res.json(newProduct); res.send(`${newProduct} inserted.`); //res.redirect('/'); } catch(err){ res.send(err); } }); Data is taken from the user. The user sends the…

VIEW QUESTION

How to get expected output from MongoDB?

I'm new to MongoDB aggregation. I am not getting desired output The output I'm getting from aggregation:- [ {tweet:{key:value}}, {tweet:{key:value}}, {tweet:{key:value}}, {tweet:{key:value}}, ] but I want the following output from the pipeline:- [ {key:value}, {key:value}, {key:value}, ] and lastly, pipeline…

VIEW QUESTION
Back To Top
Search