skip to Main Content

MongoDB $lookup returning array with empty

Product Collection: [ { "isActive": true, "_id": "643bbdee68b521035e20c976", "name": "lu", "price": 123, "userId": "643abd0dcce4df3b1a0c8fa7" }, { "_id": "643bbdd668b521035e20c972", "name": "mu", "price": 123, "userId": "643abd0dcce4df3b1a0c8fa7", "isActive": true, "__v": 0 }, { "isActive": true, "_id": "643bbdbc68b521035e20c971", "name": "nu", "price": 123, "userId": "643abd0dcce4df3b1a0c8fa7"…

VIEW QUESTION

no socket io connection being made – Reactjs

All versions installed of socket.io and socket.io-client are the same in my mern app. Here is my server code: const app = express(); mongoose.connect(MONGOOSE_URL, { useNewUrlParser: true, useUnifiedTopology: true, }).then(() => { console.log(`MongoDB connected successfully`); }).catch((error) => console.log(`${error} did not…

VIEW QUESTION

Mongodb – how to mongoose delete cascade in latest version of mongoose without model.remove()?

Not able to delete cascade as Model.remove() fuction is not available in mongoose. using findByIdAndDelete is not invoking the middleware: BootcampSchema.pre('remove',async function(next){ //before deleting the doc console.log(`courses being removed from bootcamp ${this._id}`); await this.model('Course').deleteMany({bootcamp:this._id}); next(); }); tried different delete methods…

VIEW QUESTION

Mongodb – MongooseError: Model.create() no longer accepts a callback how to use async await?

app.post('/contactForm',function(req,res){ Contact.create({ name: req.body.name, phone: req.body.phone }, function(err, newContact){ if(err){ console.log(err, 'error in connectiong'); return; } console.log("*******", newContact); return res.redirect('back'); }) }) /home/ganesh/Web Dev/CN Web Dev/HTML/basics/Nodejs Workspace/contact_list/node_modules/mongoose/lib/model.js:2771 throw new MongooseError('Model.create() no longer accepts a callback');

VIEW QUESTION
Back To Top
Search