1
나는 꽤 많은 조합을 시도하고 MongoDB 3.2 문서를 확인했지만 아직 내 DB에 저장된 새 Date()를 얻지 못하고 있습니다. 아래의 모든 항목이 올바르게 저장됩니다. 모든 팁에 미리 감사드립니다! 내 app.js 파일에서
코드 :
db.collection('users').update({user: req.user.username}, {
$push: {
"recentPlays": {
"quiz": req.session.mostRecentQuiz,
"score": score
}
}
},{
$set: {
"mostRecentQuiz.quizObj": req.session.mostRecentQuiz,
"mostRecentQuiz.time" : new Date() // StackOverflow: this is the part that is not getting stored in the DB.
}
}, function (err, result) {
if (err) throw err;
console.log(result);
});
스토어 타임 스탬프 대신 개체를 시도해보십시오 : 귀하의 방법을 다시하는 것은 쓰기 "Date.now()"대신 "새로운 날짜()"답장을 보내 – Nosyara
@Nosyara 덕분에. 방금 Date.now() 시도하고 작동하지 않습니다. "new Date()"는 내 앱의 다른 곳에서 작동합니다. –