简体   繁体   English

如何使用 node.js 从 mongo DB 获取日期?

[英]How to fetch date from mongo dB using node js?

{
    status: true,
    paymentDone: true,
    type: 'MANUAL',
    _isJobExecuted: false,
    _isDeleted: false,
    _id: 60139d379fdac790a598316f,
    expiry_date: 2021-02-28T17:42:55.073Z,
    _isExecutedTime: 2021-01-29T00:00:00.000Z,
     createdAt: 2021-01-29T05:29:27.257Z,
    updatedAt: 2021-01-29T05:29:27.257Z,
    __v: 0,
    id: '60139d379fdac790a598316f',
    subscription: null,
    package: null,
    user: null
  },
let sub = subscriptionInstance.expired_date; 

this is not working,getting undefined.这不起作用,变得不确定。

Please elaborate a little more about the question, the object you define first with all keys are coming from mongo-DB or you create it statically.请详细说明这个问题,您首先使用所有键定义的 object 来自 mongo-DB,或者您静态创建它。 if you creating the object statically then you can access the key in this way.如果您静态创建 object 那么您可以通过这种方式访问密钥。

const subscriptionInstance={
status: true,
paymentDone: true,
type: 'MANUAL',
_isJobExecuted: false,
_isDeleted: false,
_id: 60139d379fdac790a598316f,
expiry_date: 2021-02-28T17:42:55.073Z,
_isExecutedTime: 2021-01-29T00:00:00.000Z,
 createdAt: 2021-01-29T05:29:27.257Z,
updatedAt: 2021-01-29T05:29:27.257Z,
__v: 0,
id: '60139d379fdac790a598316f',
subscription: null,
package: null,
user: null
},
let sub = subscriptionInstance.expired_date; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM