Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda