Sub-Schema only shows '[object Object]'

32 views
Skip to first unread message

Darin Hensley

unread,
Jul 4, 2014, 2:37:51 PM7/4/14
to mongoo...@googlegroups.com
Here is my schema:

var CpuSchema = new Schema({
    timestamp
: { type : Date, index: true },
    available
: Boolean,
    status
: String,
    metrics
: [ { duration : String,
        data
: Number,
        type
: String,
        unit
: String
   
} ,
   
{ duration : String,
        data
: Number,
        type
: String,
        unit
: String
   
},
   
{ duration : String,
        data
: Number,
        type
: String,
        unit
: String
   
}
   
]
});



But when I do a query and have a document returned, I get: 

[ { _id: 53b6d3629074ad2e59e4be6f,
    timeStamp
: Fri Jul 04 2014 16:16:38 GMT+0000 (UTC),
    available
: true,
    status
: 'n',
    __v
: 0,
    metrics
: [ '[object Object]', '[object Object]', '[object Object]' ] } ]


metrics: [ '[object Object]', '[object Object]', '[object Object]'

is unusable. What am I doing wrong and how do I make it look like the below? 



{ timestamp: 1404486663348,
  available
: true,
  status
: 'success',
  metrics
:
   
{ '15m': { data: 0.05, type: 'n', unit: 'unknown' },
     
'5m': { data: 0.01, type: 'n', unit: 'unknown' },
     
'1m': { data: 0, type: 'n', unit: 'unknown' } } }


Valeri Karpov

unread,
Jul 7, 2014, 12:45:13 PM7/7/14
to mongoo...@googlegroups.com
Are you using `console.log`? Perhaps use `util.inspect` instead?
Reply all
Reply to author
Forward
0 new messages