它是一个 mongoose/express 应用程序,我有一条这样的路线:
// ..
Posts.find({})
.then(function(posts) {
var data = _.chain(posts).filter(function(post) {
if(post.comment) {
return post.updatedAt <= post.comment.lastCreatedAt;
} else {
return true;
}
}).each(function(post) {
if(post.comment) {
post.status = 'OK';
} else {
post.status = 'NOT OK';
}
console.log("post")
console.log(post)
console.log("post.status")
console.log(post.status)
}).value();
})
// ..
但是日志是
"post"
{
_id: ***,
title: 'test',
content: 'test',
user: ***
}
"post.status"
OK
为什么第一个console.log(post)
中没有状态?
最佳答案
关于javascript - 变量没有状态键,但 var.status 给出字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36167252/