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

268
Visualizações
Mongoose : How to display in the console the content of an Object typed Mixed?

with the following data :

lines: [{ line: [12, 'Joe'] }, { line: [14, 'John'] }, { line: [6, 'Walter'] }, { line: [3, 'William'] }, { line: [18, 'Bill'] }, { line: [22, 'Albert'] }]

and the Model

const Schema = mongoose.Schema;
const Line = new Schema({
  line: [Schema.Types.Mixed]
});
const TableSchema = new mongoose.Schema({
  lines: [Line]
});

when I save then display the collection in the console I get : console.log

res.body: { __v: 0,
  _id: '590437516c71e30ee4ddcf4e',
  lines: 
   [ { _id: '590437516c71e30ee4ddcf54', line: [Object] },
     { _id: '590437516c71e30ee4ddcf53', line: [Object] },
     { _id: '590437516c71e30ee4ddcf52', line: [Object] },
     { _id: '590437516c71e30ee4ddcf51', line: [Object] },
     { _id: '590437516c71e30ee4ddcf50', line: [Object] },
     { _id: '590437516c71e30ee4ddcf4f', line: [Object] } ],

should not it be ?

   [ { _id: '590437516c71e30ee4ddcf54', line: [12, 'Joe']
   ...

why the content of the inner Array Object is not fully displayed ?

thanks for feedback

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The object is too deeply nested for console.log(), which, under the hood, uses util.inspect() to inspect objects. The default recursion depth for that function is 2.

To increase the depth to "infinity", you can use this:

console.log(util.inspect(data, { depth : null }));

Alternatively, you can make console.log() output JSON:

console.log('%j', data);
over 4 years ago · Santiago Trujillo 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