skip to Main Content

Mongodb – How to find unique couples in mongo

I'm inserting these documents: db.users.insert({user1: 'a',user2: 'b'}); db.users.insert({user1: 'b',user2: 'a'}); db.users.insert({user1: 'c',user2: 'd'}); db.users.insert({user1: 'd',user2: 'c'}); Please note that user1 and user2 are actually ObjectId, but I'm writing them as single char to better explain the issue. I need to…

VIEW QUESTION

Mongodb – mongoose code showing error of a call ack function

app.post ('/create_contact',function(req,res) { contact.create({ name :req.body.name, phone:req.body.phone },function(err,newContact) { if(err){console.log('error in creating a contact!'); return;} console.log('********',newContact); return res.redirect('back'); }); }); Errors: throw new MongooseError('Model.create() no longer accepts a callback'); ^ MongooseError: Model.create() no longer accepts a callback I tried this…

VIEW QUESTION

Mongodb – FindOne and sort in array with Mongoose

How can i get sorted data in array by "name" in categories where '_id = 63fe948a22009cbbba53b905'? My sample data: { "_id": "63fe948a22009cbbba53b905", "options": { "sort": "manual" }, "categories": [ { "priority": 0, "options": "manual", "name": "Nazwa 1", "_id": "63fe8cc76d50062ae1f53821" },…

VIEW QUESTION
Back To Top
Search