返回來的是這種數(shù)據(jù)這個對象看起來并不是數(shù)據(jù)庫中對應(yīng)的文檔而是模型,這個對象的_doc內(nèi)部屬性才是??墒俏抑苯訌纳厦嫒≈档脑捠强梢匀〉降腸onsole.log(x.date);// 1474732800000可是給文檔賦值就不行Calendar.find({ date: {$gte: firstDayOfMonth}
})
.limit(35)
.sort({ date: 1})
.then(dates => {
dates.map(x => {
x.date = moment(x.date).format('YYYY-MM-DD HH:mm:ss');
console.log(x); // { _id: 57c5a02c8890a02814771e0d, date: 1477670400000, __v: 0 }
});
res.json(dates);
});必須要對模型的x._doc.date賦值才會有效。我想知道為什么,以及如何正確的修改原文檔的數(shù)據(jù)
一個對mongooser查詢出來的數(shù)據(jù)進(jìn)行操作的問題
德瑪西亞99
2018-09-18 05:46:11