Saturday 29 April 2017

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



via erwin

No comments:

Post a Comment