无法打印object.value

时间:2016-10-17 06:49:00

标签: javascript json node.js mongodb object

我用nodejs查询mongoDB。 问题是,当mongoDB中提取的文档返回undefined时,我无法打印object.value

User.findOne({
  'account.port': f.port,
  'account.server': server.name
},
function (err, result) {
  if(!err){
    console.log('expire date ===> '+result); // returns object which mentioned below
    console.log('expire date ===> '+result.expireTime); // returns undefined
  }      
});

当我调用console.log(result)时,它按如下方式打印对象:

{ 
 _id: 57fb60caf380e20df0d59f4d,
 signupFp: 'a47d436a33edb44dfd2c45d6eb5574bd',
 signupIp: '127.0.0.1',
 password: 'd38c2a8589965d869c79ce77e4dc871e',
 email: 'someemail@example.com',
 __v: 0,
 sendEmailTime: 2016-10-10T09:35:06.405Z,
 activeKey: '61ce67b47ee15547878404d9b5bebab7',
 lastLogin: 2016-10-12T07:51:53.059Z,
 expireTime: 2016-10-14T00:00:00.000Z,
 createTime: 2016-10-10T09:35:06.386Z,
 isAdmin: false,
 isActive: true,
 account: [ { port: 5001, server: 'server 1' },{ port: 7001, server: 'server 1' } ] 
}

如何打印expireTime

0 个答案:

没有答案