2016-03-22 15 views
1

Onun bir firavunfaresi/ekspres app verir, ben böyle bir yol vardır:Bir değişken hiçbir durum anahtarı olan, ancak var.status dize

// .. 
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(); 
}) 
// .. 

Ama neden orada günlük

"post" 
{ 
    _id: ***, 
    title: 'test', 
    content: 'test', 
    user: *** 
} 
"post.status" 
OK 

olduğunu ilk console.log(post) durum yok mu?

cevap

0

sonrası sadece senin şema ve _ID özelliklerini verir özel bir toJSON yöntemi vardır demektir Document nesnedir.

Belgenin nesne temsilini toObject yöntemi ile alabilirsiniz.

İlgili konular