I'm trying to insert a document in a collection and print it but for some reason all I see are undefined. I'd appreciate any help with this. I'm new to Mongo and Node so pardon me for any noob mistakes.
Thanks!
console.log(current_tree);
globaldb.collection("tree").insertOne({"tree":current_tree},function(err, result) {
assert.equal(err, null);
console.log("Inserted a document into the restaurants collection.");
});
globaldb.collection("tree",function(err,collection){
collection.find({},function(err, companies) {
companies.forEach(function(err,company){
console.log(company);
});
});
});