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

220
Views
Query doesn't show id in document

I want to display a document, but the id field is missing, although it's in the database.

Topic.findOne({id: 31}).sort({id: -1}).limit(1)
    .then((topic) => {
      console.log(id); //null
      const newTopic = new Topic({
        id: 32,
        level: level,
        topics: topic,
        phrases: [phrases1, phrases2],
        nouns: [nouns1, nouns2, nouns3],
        verbs: [verbs1, verbs2, verbs3],
        adjectives: [adjectives1, adjectives2, adjectives3],
      });
      newTopic.save();
      res.redirect("/admin/panel")
    });
//console.log output
  {
    _id: new ObjectId("620eb4d998b1747bbe24c672"),
    level: 4,
    topics: 'What is your definition of risk?',
    phrases: [ 'Risk is the...', "Anything that is/isn't..." ],
    nouns: [
      'possibility',
      'change',
      'probability',
      'fear',
      'occurrence',
      'proposition'
    ],
    verbs: [
      'to perceive',
      'to reject',
      'to involve',
      'to ruin',
      'to take',
      'to realize'
    ],
    adjectives: [ 'extraordinary', 'uncertaintly', 'different', 'unfavorable', '' ]
  },

As you can see in the image, "id" is in the document, but not shown in the console.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's because id is a getter of _id as a string, that's why you can't find it. Check this, it should answer your question: https://stackoverflow.com/a/15724424/4518630

about 4 years ago · Juan Pablo Isaza Report
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!