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
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);