Meteor-Community-Packages / mongo-collection-instances

🗂 Meteor package allowing Mongo Collection instance lookup by collection name
http://packosphere.com/dburles/mongo-collection-instances
MIT License
73 stars 27 forks source link

Feature: Returns null instead of an error. #12

Closed mariorodriguespt closed 9 years ago

mariorodriguespt commented 9 years ago

I've a scenario in which it's better to get null, instead of getting an error. I've a scenario in which I've to create client side collections, I'm getting data from the server using _publishCursor. I'm creating the collection on the client with name "context-" + contextId. This packages is really helpful but I've to wrap everything inside a try.. catch().

To avoid breaking this package for older users than me, I decided that adding a flag, as the last parameters, make possible updating the package without breaking existing code.

Cheers, Mário Rodrigues

dburles commented 9 years ago

Hey @mariorodriguespt hmm, when I originally wrote it I wasn't sure on whether I should throw an error or not, but now considering some of the uses I've seen (now including yours) I'm actually leaning towards not throwing an error by default.

mariorodriguespt commented 9 years ago

Since this is client side, every second/ms counts on the mobile. wrapping inside a try.. catch() is a little slower.

dburles commented 9 years ago

@mariorodriguespt as of 3.0 a get call will now no longer throw an error if the collection isn't found https://github.com/dburles/mongo-collection-instances/commit/d79cd7f30edc508028cb25b7d9317e3dbf2e5611

mariorodriguespt commented 9 years ago

Thanks for the update :D Cheers.