I use a dodgy fix. Set a session: Session.set(‘loaded’, ‘0’); and then have a check in the template so it shows Loading or something. Can link this up to whatever is loading in the JS also.
You can query an empty collection, no problem. You’ll just get an empty array when you find().fetch() or null when you .findOne().
The actual mongodb collection isn’t created until you insert some data, but that doesn’t stop you from creating and querying an empty Meteor Mongo collection (which gives a nice programmatic wrapper for the actual mongodb collection).
Yes I was able to reproduce that. No idea what caused this “undefined” issue. I did a meteor reset. And tried it again and I get back a result. Thats cool I just have to get rid of my if (typeof collection = “undefined”) structures
Thanks awesome. I found this article as well. https://blog.serverdensity.com/checking-if-a-document-exists-mongodb-slow-findone-vs-find/
Interesting article. I hadn’t thought about that before. Although I don’t really do enough reads in my apps to feel much of a performance hit due to that yet. (Not enough users! )