I am new to node js
I had fetched content from database Data
.
Data
consist of _id
, likechecked
from this id I want to check with Like
if the _id
exist means I want to change the value of likechecked
as 1
or else 0
Now my problem after fetching data from Data
I had itrete the fetched data for checking with Like
After checking Like I can't change the value of likechecked
Data.find().then(data => {
const user_id = "balaji@007"
for (var _id in data) {
Like.findOne({ postid: data[_id]._id,userid:user_id }).then(data2 => {
if(data2 != null){
data[_id].likechecked= 0
}else{
console.log("s")
data[_id].likechecked= 1
}
console.log(data)
});
}
}).catch(err => {
console.log(err)
});