Here is my code and I'm getting null value for the doc. But in the findOne({'webpageid':docs[i]._id} instead of docs[i]._id if I pass the webpageid it works. And I verified docs has the required webpage data
// get all the records from the webpages table
var collection = db.get('webpages');
collection.find({}, function(e,docs){
// iterate over the webpage list
for (var i = 0; i < docs.length; i++) {
// check if results table has any record for this webpage
db.get('results').findOne({'webpageid':docs[i]._id}, function(err, doc)
{
if(err)
{
return;
}
console.log(doc);
});
};
});
Below is the content in the 'webpages' table
{
"_id" : ObjectId("549608e16ecb16dc3c4880e6"),
"name" : null,
"url" : "http://www.google.com",
"texttoverify" : null,
"interval" : null,
"websiteid" : null
}
{
"_id" : ObjectId("549609986ecb16dc3c4880e7"),
"name" : null,
"url" : "http://www.google.com",
"texttoverify" : null,
"interval" : null,
"websiteid" : null
}
{
"_id" : ObjectId("54960a916ecb16dc3c4880e8"),
"name" : "xyz",
"url" : "http://www.google.com",
"texttoverify" : "hello",
"interval" : "00:15:00.0000000",
"websiteid" : "02D7BE81-4E01-4347-BAE5-BA9A2D7EE11E"
}
Here is my content inside 'results' table
{
"_id" : ObjectId("54985a1e69af082f9c477574"),
"webpageid" : "549608e16ecb16dc3c4880e6"
}
{ "_id" : ObjectId("54986f4e69af082f9c477575"), "name" : "name" }
{
"_id" : ObjectId("5498d10c69af082f9c477576"),
"name" : "name",
"webpageid" : "\"54960a916ecb16dc3c4880e8"
}
{
"_id" : ObjectId("5498d1f969af082f9c477577"),
"name" : "name",
"webpageid" : "54960a916ecb16dc3c4880e8"
}
Thanks for looking into it and appreciate your help.