2017-03-28 2 views
0

データは次のとおりです。なぜマングースcreatedAt/updatedAt出力間違った時間(だけデシベルでない時現在の時刻を返す)

{ 
    "_id" : ObjectId("58da135cfc80bc44f7653fd4"), 
    "updatedAt" : ISODate("2017-03-28T08:00:59.541Z"), 
    "createdAt" : ISODate("2017-03-28T07:40:12.742Z"), 
    "name" : "hello", 
    "delete" : false, 
    "enabledPlugins" : [ 
     ObjectId("58c24f65b363502f907738f9") 
    ], 
    "__v" : 0 
} 

私のスキーマと同様:

const mongoose = require('./db'); 
const { Schema } = mongoose; 

const templateSchema = new Schema({ 
    name: { type: String, index: true, unique: true }, 
    enabledPlugins: [ 
    { type: Schema.Types.ObjectId } 
    ], 
    delete: { type: Boolean, default: false } 
}, { 
    timestamps: true 
}); 

const Template = mongoose.model('Template', templateSchema); 

module.exports = Template; 

しかし、

exports.getAllTemplates = async function() { 
    return await Template.aggregate(
    { $match: { delete: false } }, 
    { $project: { id: '$_id', _id: 0, name: 1, enabledPlugins: 1, createdAt: 1 } } 
); 
}; 

結果のように:私はテンプレートを取得したい場合は、私が間違っているタイムスタンプを取得

[ 
    { 
    "createdAt": "2017-03-28T17:04:30.502+08:00", 
    "name": "hello", 
    "enabledPlugins": [ 
     "58c24f65b363502f907738f9" 
    ], 
    "id": "58da135cfc80bc44f7653fd4" 
    } 
] 

私はtoSSONの前に見つかった出力が間違っています。私はプラグインを一切使っていません。すべての日付タイプに同じ問題があります。

+1

を書き換えることです。レスポンスを受け取った後、 'createdAt.toUTCString()'をチェックできますか? – abdulbarik

答えて

0

おかげで、問題は、私は私はそれが時間形式の問題だと思うDate.prototype.toISOString

関連する問題