I spent over 8 hours debugging this code and finally got some help on the mongodb IRC chat room. Hacking through this code was a nightmare and hopefully posting it here will alleviate many headaches for all. The documentation is so lacking sometimes but I guess that is why we have blogs like this!
So I want to get the last value inserted based on a filter(hostName) and the special _id field built into mongodb. This is how I did it: