Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda