Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Mongo Db query to find questionId and update with user questionId

I want to find Users having some questions And after that I have to find questionId from question collection and then update the questionId to the user collection Here is the query which gives me undefined


 db.users.find({
    $and: [{
        "question": {
            "$ne": ""
        }
    }, {
        "question": {
            "$ne": null
        }
    }]
}).forEach(function(myDoc) {
    if (myDoc.question) {
        print("user_id " + myDoc.user_id + " " + myDoc.question) 
        var doc2 = db.security_que.findOne([{
            $match: {
                "que": myDoc.question
            }
        }]);
        if (doc2) {
            db.users.update({
                "user_id": myDoc.user_id,
                "question_id": myDoc.que_id
            }, {
                $set: {
                    "question_id": doc2.que_id
                }
            })
        }
    }
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!