Mongoose:如何在控制台中显示一个对象types混合的内容?

用以下数据

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

模型

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

当我保存然后在控制台显示集合我得到: 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] } ], 

不是吗?

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

为什么内部数组对象的内容没有完全显示?

感谢您的反馈

console.log()这个对象是嵌套太深的,它在util.inspect()使用util.inspect()来检查对象。 该函数的默认recursion深度是2。

要增加“无限”的深度,你可以使用这个:

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

或者,你可以使console.log()输出JSON:

 console.log('%j', data);