skip to Main Content

MongoDB Aggregation with Mongoose in Route

Messing around with aggregations in MongoDB in a Node / Express app with Mongoose. Here's the route: router.get("/search", async (req, res) => { let movies; if(req.query.search){ escapeRegex(req.query.search); const regex = new RegExp(escapeRegex(req.query.search), 'gi'); movies = await Movie.aggregate( [ { '$match':…

VIEW QUESTION

Mongodb – Mongoose POST method

I am building a MERN app where I want to use a POST method to send data to my collection in MONGODB. I imported schema as Messages here is the code app.post("/messages/new",(req,res) => { const dbMessage = req.body; Messages.create(dbMessage,(err,data) =>…

VIEW QUESTION
Back To Top
Search