I try to change an array of user in my mongodb from another collection. this is the code:
phrases.find({albumID: tileid}).toArray(function(err, results) {
if (results.length > 0) {
for(var j = 0; j < results.length; j++)
{
for(var z = 0; z < o.Phrases.length; z++)
{
if(o.Phrases[z].id == results[j]._id)
{
o.Phrases.splice(z,1);
break;
}
}
}
}
});
console.log(o.Phrases);
.
.
.
after update the collection
When I do logs, I don't see the change being made. If I do the logs in toArray blocks, I see the changes. I read alot, And dont found solution only that toArray is async function but not how to change it or to use it. Maybe there is another way to change the collection to the array. thanks for helping.